0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Byobu で 2x2 のパネルを一気に立ち上げる方法

Posted at

本記事では、Byobu を使って 2x2 にパネルを区切りながら、4つのスクリプトを個別のパネルで実行する startup スクリプトの書き方を紹介します。

本記事のゴール

byobu_2x2_fps30.gif

上の gif を実現する startup スクリプト:

run_all_2x2.sh
#!/bin/bash
# ----------
#   1 | 3
#   -----
#   2 | 4
# ----------
export SUB="${HOME}/startup_scripts/subscripts"

# Pane 1: top left
byobu new-window -n startup -- bash -c "${SUB}/sc01.sh;bash"
sleep 1

# Pane 2: bottom left
byobu split-window -v "bash ${SUB}/sc02.sh;bash"
sleep 1

# Pane 3: top right
byobu select-pane -t 0
byobu split-window -h "bash ${SUB}/sc03.sh;bash"
sleep 1

# Pane 4: bottom right
byobu select-pane -t 2
byobu split-window -h "bash ${SUB}/sc04.sh;bash"

手順

1. Byobu のインストール

sudo apt install byobu

Byobu の操作方法については、こちらが優れているので参照してください。

2. ディレクトリの作成

mkdir -p ~/startup_scripts/subscripts
cd ~/startup_scripts/subscripts

3. 個別パネルで実行するスクリプトの作成

作り方は自由です。以下は一例です。

cat << 'EOF' > sc01.sh
#!/bin/bash
echo "Hello from Script 1"
EOF

実行権限の付与もお忘れなく。

chmod +x sc01.sh

他の3つのスクリプトも同様の手順で作成します。

4. startup script の作成

冒頭のスクリプト (run_all_2x2.sh) を作成し、以下のように配置します。

startup_scripts/
├── run_all_2x2.sh   <- ここ
└── subscripts
    ├── sc01.sh
    ├── sc02.sh
    ├── sc03.sh
    └── sc04.sh

実行権限の付与もお忘れなく。

chmod +x run_all_2x2.sh

5. startup script の実行

startup script の場所に移動します。

cd ~/startup_scripts

Byobu を起動します。

byobu

startup script を実行します。

./run_all_2x2.sh

これで gif が再現できると思います。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?