脳汁portal

アメリカ在住(だった)新米エンジニアがその日学んだIT知識を書き綴るブログ

ぼくがかんがえたさいきょうの.screenrc(とAutoHotKey)

screenrc

全体像

### Under Bar Style
hardstatus alwayslastline "%H[%n] [%w]"
termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
shelltitle "$ |bash"

## active screen is red(rw)
## non active screen are blue(bw)
caption always "%?%F%{= rw}%:%{= bw}%?%H %-w%?%F%{=bu dk}%:%{=bu dc}%?%n %t%{-}%+w"

## split screen
# vertical
bind \ split -v
# horizontal(separate)
bind s split

## change screen size
# size up
bind + resize +1
# size down
bind - resize -1

### ウィンドウ操作モード(^z w でウィンドウを連続的に操作できるようになる))
bind w eval 'echo "Operate window"' 'command -c operate'

## Move screen
# Tabキーで一個前のスクリーンへ移動
bind -c operate ^] command

# iで上、jで左、nで下、kで右のスクリーンへ移動
bind -c operate i eval 'focus up' 'command -c operate'
bind -c operate j eval 'focus left' 'command -c operate'
bind -c operate n eval 'focus down' 'command -c operate'
bind -c operate k eval 'focus right' 'command -c operate'

# tでTop, bでbottomのスクリーンへ移動
bind -c operate t eval 'focus top' 'command -c operate'
bind -c operate b eval 'focus bottom' 'command -c operate'

## change screen size
bind -c operate + eval 'resize -v +1' 'command -c operate'
bind -c operate - eval 'resize -v -1' 'command -c operate'
bind -c operate > eval 'resize -h +1' 'command -c operate'
bind -c operate < eval 'resize -h -1' 'command -c operate'

# quit screen
bind Q quit

# Reload .screenrc
bind R source ~/.screenrc

各項目説明

UnderBarの設定
### Under Bar Style
hardstatus alwayslastline "%H[%n] [%w]"
termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
shelltitle "$ |bash"

## active screen is red(rw)
## non active screen are blue(bw)
caption always "%?%F%{= rw}%:%{= bw}%?%H %-w%?%F%{=bu dk}%:%{=bu dc}%?%n %t%{-}%+w"
  • 現在操作中のscreenのアンダーバーを赤色に、それ以外を青色にする
画面の分割
## split screen
# vertical
bind \ split -v
# horizontal(separate)
bind s split
  • \で横分割
  • sで縦分割
スクリーンのサイズ変更
## change screen size
# size up
bind + resize +1
# size down
bind - resize -1
  • +で1行分大きくする
  • -で1行分小さくする
Windowモード
### ウィンドウ操作モード(^z w でウィンドウを連続的に操作できるようになる))
bind w eval 'echo "Operate window"' 'command -c operate'

## Move screen
# Tabキーで一個前のスクリーンへ移動
bind -c operate ^] command

# iで上、jで左、nで下、kで右のスクリーンへ移動
bind -c operate i eval 'focus up' 'command -c operate'
bind -c operate j eval 'focus left' 'command -c operate'
bind -c operate n eval 'focus down' 'command -c operate'
bind -c operate k eval 'focus right' 'command -c operate'

# tでTop, bでbottomのスクリーンへ移動
bind -c operate t eval 'focus top' 'command -c operate'
bind -c operate b eval 'focus bottom' 'command -c operate'

## change screen size
bind -c operate + eval 'resize -v +1' 'command -c operate'
bind -c operate - eval 'resize -v -1' 'command -c operate'
bind -c operate > eval 'resize -h +1' 'command -c operate'
bind -c operate < eval 'resize -h -1' 'command -c operate'
  • wでwindowモードに移行する

(Windowモード中に)

    • iで上、jで左、nで下、kで右のスクリーンへ移動
    • tでTop, bでbottomのスクリーンへ移動
    • +/-で上下のスクリーンサイズ変更
    • で左右のスクリーンサイズ変更
その他
# quit screen
bind Q quit

# Reload .screenrc
bind R source ~/.screenrc
  • Qでスクリーン終了
  • Rでスクリーンモードを終了せずにscreercへの変更を反映

おまけ(AutoHotkey)

screenは[Ctrl+a]でscreenコマンドの待機モードになるので、この[Ctrl+a]を押す機会が非常に多くなる。
なので、AutoHotKeyというToolでCapsLockキーを押した場合、このバインドが押されたこととするようにした
ちなみにAutoHotKeyスクリプトは以下のような感じ

#z::Run www.autohotkey.com
Capslock:: ^a
sc03a::^a
^!n::
IfWinExist Untitled - Notepad
	WinActivate
else
	Run Notepad
return

; for kinesis keyboard
;$Enter::Send,{Space}
;$Space::Send,{Enter}
;$LWin::Send,{Ctrl}
;$RWin::Send,{Ctrl}
;$Ctrl::Send,{LWin}s
;Delete::Alt
;Home::Delete
;LCtrl::Home
;Alt::End
;End::LCtrl