This prompt is a fork of the awesome "Informative git prompt for bash" which has been derived from the original prompt for zsh found here
I tweaked the bash build by using an environment variable called $NODE_ENV in the informative display.
To use this fork, make sure to export NODE_ENV=whatever_you_want_to_put_here first before installing! Make sure to export this var in one of your .profile, .bash_profile or .bashrc or otherwise loaded login files.
Since we can add this export line on different machines, the NODE_ENV distinguishes operations and scripting tasks by machine. It's been used for flagging development vs. production settings in node.js. However, I find it's more helpful in distributed scenerios where messages between machines can be flagged and identified by different origin environments.
Primarily this is bash prompt that displays information about the current git repository. In particular the branch name, difference with remote branch, number of files staged, changed, etc.
This forked prompt looks like the following:
(master↑3|✚1): on branchmaster, ahead of remote by 3 commits, 1 file changed but not staged(status|●2): on branchstatus, 2 files staged(master|✚7…): on branchmaster, 7 files changed, some files untracked(master|✖2✚3): on branchmaster, 2 conflicts, 3 files changed(experimental↓2↑3|✔): on branchexperimental; your branch has diverged by 3 commits, remote by 2 commits; the repository is otherwise clean(:70c2952|✔): not on any branch; parent commit has hash70c2952; the repository is otherwise clean
By default, the general appearance of the prompt is::
(<branch> <branch tracking>|<local status>)
The symbols are as follows:
- Local Status Symbols
✔: repository clean●n: there arenstaged files✖n: there arenunmerged files✚n: there arenchanged but unstaged files…n: there arenuntracked files
- Branch Tracking Symbols
↑n: ahead of remote byncommits↓n: behind remote byncommits↓m↑n: branches diverged, other bymcommits, yours byncommits
- Branch Symbol:
When the branch name starts with a colon:, it means it's actually a hash, not a branch (although it should be pretty clear, unless you name your branches like hashes :-)
• Clone this repo to your homedir and source its entry point into your login session.
$ git clone https://github.com/reqshark/bash-git-prompt.git ~/.bash-git-prompt
$ source ~/.bash-git-prompt/gitprompt.sh• If you like, append that source command to your .bashrc or .bash_profile so gitprompt.sh script runs at login.
$ echo -e "source $HOME/.bash-git-prompt/gitprompt.sh" >> "$HOME/.bashrc"• Go in a git repository and check it out!
- You can use
GIT_PROMPT_STARTandGIT_PROMPT_ENDto tweak your prompt - If you want to tweak the colors, change all the good stuff from inside
themesdir. - You can make calls from the
prompt_callbackfunction ingitprompt.shto manage other dynamic prompt behavior.
function prompt_callback {
if [ `jobs | wc -l` -ne 0 ]; then
echo -n " jobs:\j"
fi
}