ウィンドウタイトルに今いるディレクトリを設定する

.screenrc

 #hardstatus lastline "%`%-w%{=b gw}%n %t%{-}%+w"
 hardstatus lastline "%`%-w%{=b gw}%50>%n %t%{-}%+w%<"
 shelltitle "$ |bash"

.bashrc

 function pwd2() {
   local _ifs=IFS
   local buf=''
   local dir=()
   local n=0
   local idx=0
   IFS=/
   for i in $PWD; do
     n=${#dir[@]}
     dir[$n]=$i
   done
   n=${#dir[@]}
   for i in 3 2 1; do
     idx=$((n-$i))
     if [ "$idx" -gt 0 ]; then
       buf=$buf/${dir[$idx]}
     fi
   done
   if [ "$n" -gt 2 ]; then
     buf=${buf#/}
   fi
   IFS=$_ifs
   echo -ne $buf
 }
  
 export PROMPT_COMMAND='echo -ne "\033k$(pwd2)\033\\"'

参考

http://rcmdnk.github.io/blog/2013/03/21/promt-command/


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2013-04-22 (月) 11:46:59