24 ms·
I changed mine for the first time in years, to show me which git branch I'm in, to avoid doing the wrong thing in the wrong place. davidw@fortrock:~/worksh
by davidw 17y ago
I changed mine for the first time in years, to show me which git branch I'm in, to avoid doing the wrong thing in the wrong place.
davidw@fortrock:~/workshop/langpop (master) $
- tlrobinson 17y ago+1 for the git branch. Here's my bash prompt script. It shows the command number from this session (PS_NUM), the exit code of the last command (highlighted red if != 0), the pwd (in cyan), and the git branch (in magenta) OFF="\[\033[0m\]" RED="\[\033[0;31m\]" MAGENTA="\[\033[0;35m\]" CYAN="\[\033[0;36m\]" function promptcommand { STATUS=$? PS_NUM="[\#]" PS_STATUS="[$STATUS]" PS_PWD="${CYAN}\w${OFF}" PS_GITBRANCH="${MAGENTA}\$(__git_ps1)${OFF}" PS_PROMPT="\$" if [ $STATUS -ne "0" ]; then PS_PROMPT="${RED}${PS_PROMPT}${OFF}" fi PS1="${PS_NUM}${PS_STATUS} ${PS_PWD}${PS_GITBRANCH} ${PS_PROMPT} " } PROMPT_COMMAND=promptcommand I probably could have eliminated the PROMPT_COMMAND thing like in the first example.
- dan00 17y agoIf you like that, perhaps you will like these: export GIT_PS1_SHOWDIRTYSTATE=1 export GIT_PS1_SHOWSTASHSTATE=1 export GIT_PS1_SHOWUNTRACKEDFILES=1
- dchest 17y agoHere's mine for Mercurial (shows branch and changeset number): http://gist.github.com/181764 http://gist.github.com/181764
- durin42 17y agoHere's a version that automatically DTRT for git, hg, and svn (hg last in implementation so my home doesn't override other repositories): http://bitbucket.org/durin42/dotfiles/src/tip/.shell.d/50.vcs_functions.sh#cl-160 http://bitbucket.org/durin42/dotfiles/src/tip/.shell.d/50.vc... Here's the code for the zsh prompt that uses it: http://bitbucket.org/durin42/dotfiles/src/tip/.shell.d/99.prompt.zsh http://bitbucket.org/durin42/dotfiles/src/tip/.shell.d/99.pr...
- forsaken 17y agoI use vcprompt, it works with all the major ones, and is written in C to be fast: http://vc.gerg.ca/hg/vcprompt/ http://vc.gerg.ca/hg/vcprompt/
- extension 17y agoMine shows git branch and changed file status: http://code.extension.ws/post/181469611/git-prompt-rb http://code.extension.ws/post/181469611/git-prompt-rb It's a Ruby script so not the fastest in theory, but I haven't noticed any delay using Ruby 1.9
- lvv 17y agoThere is faster version of this. In pure bash. And can do much more, including GIT, SVN and HG. Screen shots: http://volnitsky.com/project/git-prompt http://volnitsky.com/project/git-prompt