screen title 자동설정

디렉토리 변경시 타이틀 변경

 if [[ "$TERM" == screen* ]]; then
   screen_set_window_title () {
     local HPWD="$PWD"
 #    case $HPWD in
 #      $HOME) HPWD="~";;
 #      $HOME/*) HPWD="~${HPWD#$HOME}";;
 #    esac
     printf '\ek%s\e\\' "$HPWD"
   }
   PROMPT_COMMAND="screen_set_window_title; $PROMPT_COMMAND"
 fi

vim 사용시 해당파일명을 타이틀로

 if &term == "screen"
   set t_ts=^[k
   set t_fs=^[\
 
 function! ResetTitle()
     " disable vim's ability to set the title
     exec "set title t_ts= t_fs="
     " and restore it to 'bash'
     exec ":!echo -ne '\033kbash\033\\'\<CR>"
 endfunction
 
   au VimLeave * silent call ResetTitle()
   set title
 endif

* 여기서 ^[k와 ^[\ 는 아스키캐릭터로 Ctrl+v, Alt+k 조합으로 입력해야한다.

Leave a Reply

Your email address will not be published. Required fields are marked *