Tmuxは同じウィンドウでウィンドウを分割します。

Tmuxは同じウィンドウでウィンドウを分割します。

私はスクリプトでtmuxを初めて使用し、それを操作しようとしています。スクリプトを実行すると、セッションで複数の画面を接続して分割し、Puttyカラーコードを指定してバインドできるため、ALT+arrow keyこれを使用すると次のように切り替わります。次のウィンドウ。これまで私がコーディングした内容は次のとおりです。

tmux new-session -d -s PortalDB
tmux selectp -t PortalDB
tmux splitw -h -p 50
tmux attach -t PortalDB
tmux set-window-option -g window-status-current-bg yellow
tmux new-session -d -s HardwareAgent
tmux selectp -t HardwareAgent
tmux splitw -h -p 50
tmux attach -t HardwareAgent
tmux set-window-option -g window-status-current-bg blue
tmux new-session -d -s Profile
tmux selectp -t Profile
tmux splitw -h -p 50
tmux attach -t Profile
tmux set-window-option -g window-status-current-bg red
tmux new-session -d -s JoinCode
tmux selectp -t JoinCode
tmux splitw -h -p 50
tmux attach -t JoinCode
tmux set-window-option -g window-status-current-bg green


tmux bind -n M-Left select-pane -L
tmux bind -n M-Right select-pane -R
tmux bind -n M-Up select-pane -U
tmux bind -n M-Down select-pane -D

スクリプトを実行するとカラーコーディングが機能しますが、画面を水平に分割したいのですが、取得することは次のとおりです。

結果

誰でもウィンドウを均等に分割する方法を提案できますか?私が気づいたもう1つのことは、このスクリプトを実行すると、名前付きセッションに接続されている4つの異なるウィンドウが実行されることです。 1つのウィンドウで水平に4回分割するだけです。誰でもこれを行う方法を提案できますか?

ベストアンサー1

私はあまりにも多くのtmuxを実行せずにこのコードを書くより良い方法を見つけました。

tmux new-window -a -n WinSplit
tmux new-session -d -s WinSplit
tmux selectp -t WinSplit
tmux split-window -v
tmux set-window-option -g window-status-current-bg blue
tmux split-window -v
tmux split-window -v
tmux select-layout even-vertical
tmux attach -t WinSplit

おすすめ記事