背景
tmuxにgitリポジトリ名を表示したくなった。
私のtmuxの設定状況は.tmux.confとgitReposName.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