2016-06-21 14 views
2

3で画面を分割し、各区画でコマンドを実行するbashスクリプトを作成しています。bashスクリプトからtmuxを使用して画面を分割する方法

私は基本的にbashスクリプトを実行したいと思いますし、bashスクリプトは3で画面を分割し、もう1つのペインでhtop、3番目のペインでperl re.plを実行します。

助けや指導は感謝しています!

答えて

3

これを実行するための直接的な方法は、デタッチセッションを作成ペインを作成し、は、そのセッションにを添付することです。

# -d says not to attach to the session yet. top runs in the first 
# window 
tmux new-session -d top 
# In the most recently created session, split the (only) window 
# and run htop in the new pane 
tmux split-window -v htop 
# Split the new pane and run perl 
tmux split-pane -v perl re.pl 
# Make all three panes the same size (currently, the first pane 
# is 50% of the window, and the two new panes are 25% each). 
tmux select-layout even-vertical 
# Now attach to the window 
tmux attach-session 

また、tmuxは、1回の呼び出しでこれを行う、おそらくスクリプトからこれを行う理由はないことができます。

tmux new-session -d top \; split-window -v htop \; split-window -v perl re.pl \; select-layout even-vertical \; attach-session 
+1

分割ペインがために、2.3のためのドキュメントでは使用できません。なんらかの理由でhttp://manpages.ubuntu.com/manpages/zesty/en/man1/tmux.1.html#contenttoc6スプリットペインが実際に使用されたときにtmuxが文句を言うことはありません – gmile

+0

Hm。いつ削除されたのか、理由は分かりませんでしたが、 'split-window -t 'が置き換えられているようです。 (それを考えると、 'split-window'と' split-pane'コマンドは別々に見えます;すべてのウィンドウには少なくとも1つのペインが含まれているので、実際にウィンドウを分割することはありません)。 – chepner

1

私はこれにtmuxinatorを使用しています。設定ファイルでウィンドウごとにウィンドウとペインを定義し、次にそのウィンドウで使用できます。

tmuxinator start <some-name> 

これは本当に素敵です!

(私はまた、純粋なbashのでこれを行うことが可能であると確信しています。)

関連する問題