-
-
Save kenjis/b33dfbccd2d1e758362ebeb0a7324253 to your computer and use it in GitHub Desktop.
Mac OS X - Install Git Completion
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
URL_COMP="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash" | |
URL_PROMPT="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh" | |
#PROFILE="$HOME/.profile" | |
PROFILE="$HOME/.bash_profile" | |
#PROFILE="$HOME/.bash_aliases" | |
echo "Downloading git-completion..." | |
if ! curl "$URL_COMP" --silent --output "$HOME/.git-completion.bash"; then | |
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1 | |
fi | |
echo "Downloading git-prompt..." | |
if ! curl "$URL_PROMPT" --silent --output "$HOME/.git-prompt.sh"; then | |
echo "ERROR: Couldn't download prompt script. Make sure you have a working internet connection." && exit 1 | |
fi | |
SOURCE_LINE="source ~/.git-completion.bash" | |
if [[ -f "$PROFILE" ]] && grep -q "$SOURCE_LINE" "$PROFILE"; then | |
echo "Already added git-completion to bash profile." | |
else | |
echo "Adding git-completion to bash profile..." | |
echo "$SOURCE_LINE" >> "$PROFILE" | |
fi | |
SOURCE_LINE="source ~/.git-prompt.sh" | |
if [[ -f "$PROFILE" ]] && grep -q "$SOURCE_LINE" "$PROFILE"; then | |
echo "Already added git-prompt to bash profile." | |
else | |
echo "Adding git-prompt to bash profile..." | |
echo "$SOURCE_LINE" >> "$PROFILE" | |
echo << EOL | |
GIT_PS1_SHOWDIRTYSTATE=true | |
GIT_PS1_SHOWUPSTREAM=auto | |
GIT_PS1_SHOWUNTRACKEDFILES=true | |
GIT_PS1_SHOWSTASHSTATE=true | |
export PS1='\[\033[1;32m\]\u@\h\[\033[00m\]:\[\033[1;34m\]\w\[\033[1;31m\]$(__git_ps1)\[\033[00m\]\$ ' | |
EOL | |
fi | |
echo "Reloading bash profile..." | |
source "$PROFILE" | |
echo | |
echo "Successfully installed." | |
echo "Git auto-completion should be all set!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment