Is there any file that accurev reads when login?
In linux, I need once I login to accu开发者_如何转开发rev, the PS1 changes to the following:
suppose my workspace placed in the path ~/myfiles/accurev/ws/myworkspace
<username>@<machineName> : ACCUREV >
so, when I for example cd to ~/myfiles/accurev/ws/myworkspace/myproject1/org/daz/
,
the PS1 be :
<username>@<machineName> : ACCUREV/myproject1/org/daz >
You can use the data in accurev info
to pull this off. But doing it on every prompt load might get annoying since the command takes a few seconds to complete. You could maybe temper that by checking if your PWD has changed and only run it when changing directories.
For example, here's a way to get the path of your PWD relative to accurev info's 'Top':
pwd | cut -b`accurev info 2>/dev/null | grep Top | awk '{print $2}' | wc -c | awk '{print $1}'`- 2>/dev/null
You could drop this into PS1, but then every prompt will take 1-2 extra seconds. If you wanted to do it only on directory changes you could probably use PROMPT_COMMAND to do the work but only if PWD != OLDPWD
.
So. Doable? yes. Worth it? hard to say.
Oh, and as for your colors. Check out https://github.com/matschaffer/profile, specifically https://github.com/matschaffer/profile/blob/master/environment.conf for the PS1 definition at the bottom. That should give you some ideas.
You should enter your workspaces with the following command:
accurev start -w myworkspace
Then in your .bashrc add the following:
if [ "${ACCUREV_TOPDIR}" != "" ]
then
PS1='[\u@\h `pwd | sed -e "s#${ACCUREV_TOPDIR}#ACCUREV#"`]\$ '
else
PS1='[\u@\h \W]\$ '
fi
export PS1
I personally prefer to see the workspace as well like:
PS1='[\u@\h `pwd | sed -e "s#${ACCUREV_TOPDIR}#WS(${ACCUREV_WSPACE})#"`]\$ '
精彩评论