vimã¨tmuxã®ã¹ãã¼ã¿ã¹ã©ã¤ã³ãé£æºããã¦ã¿ãã
å°ãåãããã£ã¦ã¦æå¤ã¨ä¾¿å©ã ã£ãã®ã§ç´¹ä»ã
(ãããéè¦ã¯æ¥µãã¦ä½ãã¨æããã)
ä»åç´¹ä»ããæ¹æ³ã§ã¯ tmux-powerline ã¨ããtmuxã®ã¹ãã¼ã¿ã¹ã©ã¤ã³ãpowerline風ã«ãã¦ãããã¹ã¯ãªããã使ç¨ãã¾ãã
ãã ããtmux-powerlineã使ç¨ããªãã¦ããèªèº«ã§å¿ è¦ãªé¨åãä½ããããã¨ã§ã対å¿ã§ãã¾ãã
vim 㨠tmux ãé£æºãã¦ã¿ã
ã¾ãã¯å®æå³ãè¦ã¦é ãã¾ãããã
以ä¸ã¯é常æã® tmux-powerline ã使ç¨ããã¿ã¼ããã«ç»é¢ã§ãã
tmuxã®ã¹ãã¼ã¿ã¹ã©ã¤ã³ã«æ³¨ç®ãã¦ä¸ããã
(表示æ
å ±ãå¤ãããæ°ãããããããã¯æ°ã«ããªãã§ãã ããã)
ç¶ãã¦ãvim ãèµ·åããæã®ã¿ã¼ããã«ç»é¢ã§ãã
ãããã§ãããã
tmuxã®ã¹ãã¼ã¿ã¹ã©ã¤ã³ãã¬ã©ãªã¨å¤ãã£ããã¨ã«æ°ã¥ããã§ããããã
vimèµ·åå¾ã®ã¹ãã¼ã¿ã¹ã©ã¤ã³ã«ã¯ã
vimå
ã§é¸æããã¦ãããããã¡ã®ãã£ã¬ã¯ããªãã¹ã¨ãã®ãã£ã¬ã¯ããªã® git status ã表示ããã¦ãã¾ãã
ã·ã§ã«ã®ã«ã¬ã³ããã£ã¬ã¯ããªã§ã¯ããã¾ããã
vim å
ã§ãããã¡ã移åããã°ãã¹ãã¼ã¿ã¹ã©ã¤ã³ãæ´æ°ããã¾ãã
ã¾ããvimãçµäºããããtmuxå
ã§å¥ã¦ã£ã³ãã¦ãå¥ãã¤ã³ã«ç§»åããå ´åã«ããããã«å¿ãã¦æ´æ°ããã¾ãã
ããã§ãã¤ã§ããã²ã¨ç®ã§ãããã¡ã®ãã£ã¬ã¯ããªã¨gitã®ç¶æ ã確èªã§ãã¾ãã
tmux-powerlineã«ã¤ãã¦
tmux-powerlineã®å°å
¥æ¹æ³ã«ã¤ãã¦ã¯ãããã§ã¯çããã¦é ãã¾ãã
å
¬å¼ã®readmeãèªããªããã¦å°å
¥ãã¦ä¸ããã
ãã ãtmux-powerlineå°å ¥æã«å°ãã ã注æãããã¾ãã
tmux-powerline ã¯2012å¹´12æåã°ãããã«å¤§å¹
ãªãã¼ã¸ã§ã³ã¢ãããè¡ããããããéå»ã®å°å
¥è¨äºãå½¹ã«ç«ããªããªã£ã¦ãã¾ãã
ææ°çã®å°å
¥æ¹æ³ã¯å
¬å¼readmeãè¦ãå¿
è¦ãããã¾ãã
(æ°verã® tmux-powerline ã®å°å
¥æ¹æ³ã«ã¤ãã¦è¯ãæãã«èª¬æãã¦ãããã¼ã¸ããã£ãã®ã§ããã失念ãã¦ãã¾ãã¾ãã)
ããã¨ãtmux-powerlineå°å
¥æã«å¿ããã¡ãªè¨å®ãããã¾ãã
è¨å®ããªããä¸é¨æ©è½ãé¤ãã°åä½å¯è½ãªã®ã§ã§ãããä»åã®è©±ã§ã¯å¿
è¦ãªã®ã§ããã ãæ¸ãã¦ããã¾ãã
(å
¬å¼readmeã«ã¯æ¸ããã¦ãã¾ã)
bashã®å ´å㯠.bashrc ã«ä»¥ä¸ã®è¨å®ãã
PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#D" | tr -d %) "$PWD")'
zshã®å ´å㯠.zshrc ã«ä»¥ä¸ã®è¨å®ã追å ãã¦ä¸ããã
PROMPT+='$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#D" | tr -d %) "$PWD")'
ããããããã³ããã«è¨å®ã追å ãã¦ãã¾ãããããã³ããã®è¡¨ç¤ºå 容ã«ã¯å½±é¿ãã¾ããã®ã§ãå¿é ãªãã
å°å ¥æ¹æ³
é ããªãã¾ããããå°å ¥æ¹æ³ã®èª¬æããã¦ããã¾ãããã
ã¾ãã.vimrc ã«ä»¥ä¸ã®è¨å®ãè¨è¿°ãã¾ãã
if exists('$TMUX') autocmd MyAutoCmd BufEnter * call <SID>set_vim_cwd_to_tmux() autocmd MyAutoCmd VimLeave * call <SID>del_vim_cwd_from_tmux() endif function! s:set_vim_cwd_to_tmux() if !exists('$TMUX') return endif let pain_id = system('tmux display -p "#D" | tr -d "%" | tr -d $"\n"') call system('tmux setenv ' . "TMUX_VIM_CWD_" . pain_id . ' ' . getcwd()) let bt = &buftype let ft = &filetype " let bn = bufname('%') if bt ==# 'nofile' || ft ==# 'qf' || ft ==# 'quickrun' let pwd = getcwd() else let pwd = expand('%:p:h') endif let var_name = system('tmux display -p "TMUXPWD_#D" | tr -d "%" | tr -d $"\n"') call system('tmux setenv ' . var_name . ' ' . shellescape(pwd)) endfunction function! s:del_vim_cwd_from_tmux() if !exists('$TMUX') return endif let var_name = system('tmux display -p "TMUX_VIM_CWD_#D" | tr -d "%" | tr -d $"\n"') call system('tmux setenv -u ' . var_name) endfunction
ç°¡åã«èª¬æããã¨ã
ãããã¡ç§»å(BufEnter)æã«ãtmux ã®ç°å¢å¤æ° TMUX_VIM_CWD_#D ã« vim ã®ã«ã¬ã³ããã£ã¬ã¯ããª(cwd)ã®ãã¹ãè¨å®ããTMUXPWD_#D ã« vim ã®ãããã¡ãã£ã¬ã¯ããªã®ãã¹ãè¨å®ãã¦ãã¾ãã
ããã«ãvimçµäº(VimLeave)æã«ã¯ãTMUX_VIM_CWD_#D ãåé¤ãã¦ãã¾ãã
TMUXPWD_#D 㯠tmux-powerline ã pwd ãå¤å®ããã®ã«ä½¿ç¨ãã¦ããç°å¢å¤æ°ã§ãã
ãã®å¤æ°ã¯åé¤ããå¿
è¦ã¯ããã¾ãããã·ã§ã«ã®ããã³ããæ´æ°æã«èªåçã«æ´æ°ããã¾ãã
TMUX_VIM_CWD_#D ã¯ä»åæ°ãã«ç¨æããç°å¢å¤æ°ã§ãã
ç¶ãã¦ãtmux-powerline ã®ãã¼ãè¨å®ãã¡ã¤ã«ãå¤æ´ãã¾ãã
ããã©ã«ãã®ãã¼ãã使ç¨ãã¦ããå ´åã¯ãtmux-powerline/themes/default.sh ãå¤æ´ãã¦ä¸ããã
èªèº«ã§ç¨æãããã®ã使ç¨ãã¦ããå ´åã¯ããã¡ãã使ç¨ãã¦ä¸ããã
# Format: segment_name background_color foreground_color [non_default_separator] vim_cwd=$(tmux showenv $(tmux display -p 'TMUX_VIM_CWD_#D' | tr -d '%') 2> /dev/null) vim_cwd=${vim_cwd#*=} if [ -n "$vim_cwd" ]; then # vim èµ·åæã®ã¹ãã¼ã¿ã¹ã©ã¤ã³è¨å® if [ -z $TMUX_POWERLINE_LEFT_STATUS_SEGMENTS ]; then TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=( "tmux_session_info 148 234" \ "hostname 63 255" \ "vcs_branch 29 88" \ "vcs_compare 60 255" \ "vcs_staged 64 255" \ "vcs_modified 9 255" \ "vcs_others 245 0" \ ) fi if [ -z $TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS ]; then TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS=( "pwd 89 211" \ #"vim-cwd 21 231" \ "date_day 235 136" \ "date 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ "time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ ) fi else # vimæªèµ·åæã®ã¹ãã¼ã¿ã¹ã©ã¤ã³è¨å® # 以ä¸ã¯ tmux-powerline ããã©ã«ãã®ãã¼ãã§ãã if [ -z $TMUX_POWERLINE_LEFT_STATUS_SEGMENTS ]; then TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=( "tmux_session_info 148 234" \ "hostname 33 0" \ #"ifstat 30 255" \ #"ifstat_sys 30 255" \ "lan_ip 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" \ "wan_ip 24 255" \ "vcs_branch 29 88" \ "vcs_compare 60 255" \ "vcs_staged 64 255" \ "vcs_modified 9 255" \ "vcs_others 245 0" \ ) fi if [ -z $TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS ]; then TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS=( #"earthquake 3 0" \ "pwd 89 211" \ "mailcount 9 255" \ "now_playing 234 37" \ #"cpu 240 136" \ "load 237 167" \ #"tmux_mem_cpu_load 234 136" \ "battery 137 127" \ "weather 37 255" \ #"rainbarf 0 0" \ #"xkb_layout 125 117" \ "date_day 235 136" \ "date 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ "time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ #"utc_time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ ) fi fi
ä¸è¨ã¯ä¸ä¾ã§ãã®ã§ããèªç±ã«å¤æ´ãã¦ä¸ããã
ã¾ãããããã¡ã®ãã£ã¬ã¯ããªã§ã¯ãªãvimã®ã«ã¬ã³ããã£ã¬ã¯ããªã表示ããããå ´åã¯ãä¸è¨ã¹ã¯ãªããã segment ãã£ã¬ã¯ããªã«è¿½å ãããã¼ãè¨å®ãã¡ã¤ã«ã« vim-cwd ã追å ãã¦ä¸ããã
ã¡ãªã¿ã«ç§ã®è¨å®ã¯ä»¥ä¸ã«ããã¾ãã®ã§ãåèã«ã©ããã
以ä¸ã§ãã