Created
May 10, 2009 06:19
-
-
Save igal/109520 to your computer and use it in GitHub Desktop.
My bash prompts: short, long, and git status
This file contains 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
# My bash prompts. To use, source the code below and call the name of the function, e.g. "shortprompt". | |
# Display smiley indicator for return values, date, and truncated path, e.g.: | |
### igal@avijja:z #13 12:37 :) | |
shortprompt() { | |
export PS1="\u@\h:\W #\! \A \`if [ \$? == 0 ]; then echo \:\); else echo \:\(; fi\` " | |
} | |
# Display shortprompt, but with non-truncated path, e.g.: | |
### igal@murad:~/mtmp/rubyfix #17 23:40 :) | |
longprompt() { | |
export PS1="\u@\h:\w #\! \A \`if [ \$? == 0 ]; then echo \:\); else echo \:\(; fi\` " | |
} | |
# Display git branch information, e.g.: | |
### openconferenceware::master :) | |
gitprompt() { | |
# Extract git branch information | |
function parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo ${ref#refs/heads/} | |
} | |
# Define shell prompt | |
export PS1="\W::\`parse_git_branch\` \`if [ \$? == 0 ]; then echo \:\); else echo \:\(; fi\` " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment