ウィンドウタイトルに今いるディレクトリを設定する
.screenrc
#hardstatus lastline "%`%-w%{=b gw}%n %t%{-}%+w"
hardstatus lastline "%`%-w%{=b gw}%50>%n %t%{-}%+w%<"
shelltitle "$ |bash"
.bashrc
function screen_title {
if [ "$TERM" != "screen" ]; then
return
fi
local dirs=
local path=
local i=
_IFS=IFS
IFS='/'
i=0
for d in $PWD; do
dirs[$i]=$d
i=$((i+1))
done
IFS=$_IFS
i=${#dirs[@]}
for n in $(($i-3)) $(($i-2)) $(($i-1)); do
if [ $n -gt 0 ];then
if [ -n "${dirs[$n]}" ]; then
path="${path}${dirs[$n]}/"
fi
fi
done
if [ $i -le 4 ]; then
path="/$path"
fi
if [ "$path" != "/" ]; then
path=${path:0:$((${#path}-1))}
fi
if [ ${#path} -gt 29 ]; then
path=`echo ${path:$((${#path}-29))}`
fi
echo -en "\033k$path\033\134"
}
export PROMPT_COMMAND='screen_title'