- 追加された行はこの色です。
- 削除された行はこの色です。
* ウィンドウタイトルに今いるディレクトリを設定する [#c828c1e2]
** .screenrc [#q35ffcc2]
#hardstatus lastline "%`%-w%{=b gw}%n %t%{-}%+w"
hardstatus lastline "%`%-w%{=b gw}%50>%n %t%{-}%+w%<"
shelltitle "$ |bash"
** .bashrc [#z87bcfd6]
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))
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
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
n=${#dir[@]}
for i in 3 2 1; do
idx=$((n-$i))
if [ "$idx" -gt 0 ]; then
buf=$buf/${dir[$idx]}
fi
done
if [ $i -le 4 ]; then
path="/$path"
if [ "$n" -gt 2 ]; then
buf=${buf#/}
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"
IFS=$_ifs
echo -ne $buf
}
export PROMPT_COMMAND='screen_title'
export PROMPT_COMMAND='echo -ne "\ek$(pwd2)\e\\"'