Last active
July 3, 2017 13:14
-
-
Save jbnv/78ce47382faf454553ef to your computer and use it in GitHub Desktop.
My standard shell prompt script. Show current git branch in the prompt, if there is one. Show current path in the prompt. Replace home path with "~". Replace "/var/www" with "%".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parse_git_branch () { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
| } | |
| parse_pwd () { | |
| pwd | sed -e 's#/var/www/#%#' | sed -e 's#/home/myusername#~#' | |
| } | |
| prompt () { | |
| echo "$BRANCH_COLOR\$(parse_git_branch)$USERNAME_COLOR`whoami`$PATH_COLOR\$(parse_pwd)$PROMPT_COLOR " | |
| } | |
| USERNAME_COLOR="\[\033[0;37m\]" #gray | |
| BRANCH_COLOR="\[\033[0;33m\]" #yellow | |
| PATH_COLOR="\[\033[1;32m\]" #green; bold | |
| PROMPT_COLOR="\[\033[0m\]" #none (white) | |
| PS1="$(prompt)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment