Created
June 3, 2011 15:31
-
-
Save hynkle/1006533 to your computer and use it in GitHub Desktop.
git tab completion and prompt in bash
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
# Source the git-completion script. | |
# Your location may vary. | |
# If you don't have it, you can find it at | |
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash | |
source /usr/local/git/contrib/completion/git-completion.bash | |
# If you want tab completion to work with your shell aliases for git, you'll have to do some extra work. | |
alias gco='git checkout' | |
complete -o default -o nospace -F _git_checkout gco | |
# And now the prompt. | |
# It will look like "current_working_directory ⚡ " if you're not in a git repo, | |
# and "current_working_directory (branchname) ⚡ " if you are. | |
export PS1='\W$(__git_ps1 " (%s)") ⚡ ' | |
# Actually my prompt looks like this, with some color codes: | |
# export PS1="\[${BGreen}\]\W\$(__git_ps1 \" \[${BPurple}\](%s)\") \[${BIYellow}\]⚡ \[${Color_Off}\]" | |
# The color code constants are from http://wiki.archlinux.org/index.php/Color_Bash_Prompt . | |
# Note that the $ before the call to __git_ps1 is now escaped with a backslash to defer execution | |
# while still allowing the color constants to be executed once. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment