Skip to content

Instantly share code, notes, and snippets.

@shout-poor
Created May 9, 2017 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shout-poor/35006492f1c1b81a7502c02cada9262a to your computer and use it in GitHub Desktop.
Save shout-poor/35006492f1c1b81a7502c02cada9262a to your computer and use it in GitHub Desktop.
Install git-completion & git prompt (for bash)
#!/bin/bash
#
# git-completion & git-prompt を導入するスクリプト(for bash)
# git, curl, unzip を事前にインストールしておくこと
#
set -eux
set -o pipefail
TEMPDIR=$(mktemp -d)
cd $TEMPDIR
curl -LsS https://github.com/git/git/archive/master.zip -o git-master.zip
unzip git-master.zip
cp git-master/contrib/completion/git-completion.bash $HOME/.git-completion.bash
cp git-master/contrib/completion/git-prompt.sh $HOME/.git-prompt.sh
cd $HOME
chmod +x .git-completion.bash
chmod +x .git-prompt.sh
cat << 'EOT' >> $HOME/.bashrc
source $HOME/.git-completion.bash
source $HOME/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUPSTREAM=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWSTASHSTATE=1
export PS1='\[\033[1;32m\]\u\[\033[00m\]:\[\033[1;34m\]\w\[\033[1;31m\]$(__git_ps1)\[\033[00m\]\n\$ '
EOT
if [ -d "$TEMPDIR" ]; then
rm -r "$TEMPDIR"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment