GNU screenの設定

投稿者: | 2005-07-21

GNU screenの設定のメモ.

hardstatus alwayslastline "%{= BW} %?%-Lw%{cW}%50>%n%f* %t%{-}%+Lw%<%:%w%? %="
caption always "%?%F%{= cW}%? %n %t"
%?xx%:yy%?
xxがあればxxを,そうでなければyyを表示
%{= FB}
文字の色をFに,背景をBに変える.元に戻すには%{-}
%xx>yy%<
yyが左からxx%の位置にくるようになる
%=
右端まで伸ばす
# ^T^Cでウインドウ作ったときはカレントディレクトリをいじります
bind ^C eval "screen" 'stuff "cd "' 'stuff "\047"' "paste !" 'stuff "\047"' 'stuff "^M"' 'stuff "^L"'

新しく作成したウィンドウのカレントディレクトリを変更する.どっかからの拾い物.これをするには,.bashrcあたりに以下を追加.

prompt_command() {
if [ "x$WINDOW" != "x" ]; then
screen -X register ! "`pwd`"
fi
}
PROMPT_COMMAND=prompt_command

これで,コマンドを打つたびにprompt_command()が呼ばれ,逐次screenにカレントディレクトリが保存されるようになる.

monitor off
screen -t "console" 0
monitor on
screen -t "emacs" 1
monitor on
screen -t "shell" 2
monitor on
screen -t "filer" 3
monitor off
screen -t "emacs-riece" 10

あらかじめウィンドウを作成する.作成したウィンドウでは始めにプログラムが起動されるが,それは.bashrcで指定する.

initscreen()
{
case "x$WINDOW" in
# "x0")
# cd && tail -F /var/log/messages;;
"x1")
cd && emacs -nw;;
"x2")
cd;;
"x3")
cd && mfiler;;
"x10")
cd && emacs -nw -f riece;;
esac
}
case "x$SHLVL" in
"x2")
initscreen
;;
esac