2020年11月5日 星期四

My Favorite Git Setting (for Ubunut)


1. Add the following in ~/.bash_profile


#! /bin/bash
#-----------------------------------------------------------------
# Bash autocompletion for Git

if [ -f ~/.git-completion.sh ]; then
   source ~/.git-completion.sh
fi

if [ -f ~/.git-prompt.sh ]; then
   source ~/.git-prompt.sh
fi

# PS1 may be replaced
 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\][\w]\[\033[0m\]\[\033[1;36m\]$(__git_ps1)\[\033[0;33m\]\[\033[0m\]$ '
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\w \[\033[0m\]\[\033[1;36m\] $(__git_ps1)\[\033[0;33m\]\[\033[0m\]$ '
#PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
#PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(git_since_last_commit)\[\033[0m\]$ "
#PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;33m\]\$(__git_ps1)\[\033[0;33m\]\[\033[0m\]$ "


2. Download  https://github.com/git/git/blob/master/contrib/completion/git-completion.bash 

and rename by git-completion.sh

3. download https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh

$ mv git-completion.sh ~/.git-completion.sh
$ mv git-prompt.sh ~/.git-prompt.sh
$ chmod 775 .git-completion.sh
$ chmod 775 .git-prompt.sh


4. 

$ source ~/.bashrc

or


$ source ~/.bash_profile

Reference result




沒有留言:

張貼留言