🛠️
AWSのEC2(Amazon Linux 2)プロンプトにgit-promptを適用
1. gitをインストール
$ sudo yum update
$ sudo yum install -y git
$ sudo git version
2. git-promptとgit-completionをダウンロード
$ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh
$ chmod a+x ~/.git-prompt.sh
$
$ wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -O ~/.git-completion.bash
$ chmod a+x ~/.git-completion.bash
3. .bashrcに追記
.bashrc
# User specific aliases and functions
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\[\033[36m\]\u:\W\[\033[0m\]$(__git_ps1)$ '
fi
Discussion