LoginSignup
0
0

More than 3 years have passed since last update.

【ターミナル】Bashの設定

Last updated at Posted at 2020-04-08

経緯

初期状態のターミナルが見辛かったので「時間、hostname、現在のディレクトリ、ブランチ名」が表示されるように設定した。

方法

.bash_profile に追記

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

.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[1;33m\]\t \[\033[1;31m\]\u@\h \[\033[1;35m\]\w/\[\033[31m\]$(__git_ps1)\[\033[00m\]\n\$ '

export TERM=xterm-color
export LSCOLORS=gxfxcxdxbxegedabagacad
alias ls='ls -FG'
alias ll='ls -ahlFG'

シングルクォートが違くて15分くらい気がつかなかった……
「’」->「'」のような違いがあるかもしれないので注意。(自戒)

作成した. bashrcを読み込む

source ~/.bashrc

おまけ

色を自分の好きな色にしたい場合は、.bashrc 内の「PS1=…」部分にある、mの前の数字2桁が色を表しているので、修正する。

30:黒
31:赤
32:緑
33:黄
34:青
35:紫
36:水
37:灰

まとめ

見やすくてスペシャルハピネス!一手間を惜しんではいけない。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0