LoginSignup
3
2

More than 5 years have passed since last update.

tmux の status-lineにリポジトリ名表示

Last updated at Posted at 2016-11-20

背景

tmuxにgitリポジトリ名を表示したくなった。
私のtmuxの設定状況は.tmux.confgitReposName.sh参照です。

ソース

シェルを実行して、リポジトリ名を取得しています。更新間隔は頻度が多いとPCに優しくないので一旦60秒に設定した。

.tmux.config
set  -g  status-interval 60
unbind ,
setw -g window-status-format '#[fg=white,bg=colour234] #(cd #{pane_current_path} && sh ~/gitReposName.sh) '
setw -g window-status-current-format '#[fg=colour234,bg=colour39] #(cd #{pane_current_path} && sh ~/gitReposName.sh) #[fg=colour39,bg=colour234,nobold]'
gitReposName.sh
gitRevParse=`git rev-parse --show-toplevel 2>/dev/null|tr -d '\n'`
if [ 0 < $gitRevParse ]; then
    echo `basename $gitRevParse`
else
    echo `basename $(pwd)`
fi
3
2
0

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
3
2