1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Screenコマンドで起動時にバッファを複数枚(タブみたいに)表示する.screenrc

Last updated at Posted at 2019-07-08

概要

このエントリでは、Un*x系の1つのターミナルで複数のバッファを開けるようにするGNU Screenの設定を紹介します。

できるもの

下図のような形で、screen起動時に複数のバッファが開くようになります。

スクリーンショット 2019-07-09 7.17.28.png

使い方

以下のようなコマンドを個人的にはよく使います。後述の設定ファイルをホームディレクトリの「.screenrc」ファイルとして保存すると使えるキーバインディングを含みます。

項目 キー 備考
コマンドを入力 Ctrl-j ScreenのデフォルトがCtrl-Aなのですが、これだとemacs系・macOS系のバインディングとかぶるので
コピーモードにする Ctrl-j ESC こうすると、ホイールやカーソルキーでバッファを戻れます
コピーモードから抜ける ESC
前のバッファ F11
次のバッファ F12
バッファを指定して切り替え Ctrl-j 番号 例:ctrl-j 1 で2番目のバッファ
バッファを指定して切り替え Ctrl-" (カーソルで選択) バッファ上に一覧が出るので選択
バッファ上のプロセスを止める Ctrl-k シェルを抜けるにはexit
バッファの名前を変える Ctrl-j A
選択範囲をscreenのクリップボードにコピー space
screenのクリップボードからペースト Ctrl-j [ 上記でscreenのクリップボードに入っているものが対象

設定ファイル

Gist におきました。

# screenrc
# 
# see also
#
# arch linux wiki
#   https://wiki.archlinux.org/index.php/GNU_Screen
# GNU Screen manual
#   https://www.gnu.org/software/screen/manual/screen.html#Overview

# scroll buffer (press Ctrl-J esc to enter copy-mode, press ESC to leave copy-mode)
defscrollback 20000

# change ctrl-a bindings to ctrl-j
escape ^Jj

# enable scrolling
termcapinfo xterm* ti@:te@

# avoid editors not to quit abnormally
altscreen on

# status line (show buffers)
hardstatus alwayslastline "%{= cd} %-w%{= wk} %n %t* %{-}%+w"

# do not show startup message
startup_message off

# do not change width & height on startup
termcapinfo  xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l

# press F11 to previous tab 
bindkey -k F1 prev
# press F12 to previous tab 
bindkey -k F2 next

# show some buffers on startup
screen -M -t Shell 0 
screen    -t Shell 1 
# screen    -t Shell 2
# screen    -t Shell 3
select 0

curlを使ってGistからローカルにコピペして使うことができます。
curl -L -o ~/.screenrc https://gist.githubusercontent.com/hrkt/defa67eef890a5469db3297d510e7a8d/raw

参考サイト

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?