Gitの補完やら、ブランチ名表示やらをbashでしようとしたらエラーが出る
まず、以下の記述を ~/.bashrc に記述する。
source /usr/local/etc/bash_completion.d/git-prompt.sh
source /usr/local/etc/bash_completion.d/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
コンソールを再起動または、 source ~/.bashrc すると反映されるが、
ここで自分は以下のエラーが出てできなかった。
-bash: /usr/local/etc/bash_completion.d/git-prompt.sh: No such file or directory
-bash: /usr/local/etc/bash_completion.d/git-completion.bash: No such file or directory
// (このエラーも出た)
__git_ps1: command not found
そもそも、便利機能のシェルがないぜっ、ってことみたい。
(brewでgitを入れている人は問題ない?)
ってことで便利機能のシェルをダウンロードしてくることにした。
wgetなりcurlなりで以下の場所からダウンロードする。
// git-prompt.sh のダウンロード
wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
// git-completion.sh のダウンロード
wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
ダウンロードした二つのファイルを以下に保存。
/usr/local/etc/bash_completion.d/
これでOKでした。
Author And Source
この問題について(Gitの補完やら、ブランチ名表示やらをbashでしようとしたらエラーが出る), 我々は、より多くの情報をここで見つけました https://qiita.com/gekkoukisi/items/22cc855700a19a2f2c20著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .