使用 TMUX 在终端中启动 2 个垂直窗格
Launch 2 vertical panes in terminal using TMUX
我想使用 tmux 在终端 window 中并排启动 2 个窗格:
tmux \
--vertical-pane='tsc -w' \
--vertical-pane='nodemon --watch' \
虽然我认为很有可能做到,但很难通过文档弄清楚如何做到这一点。
我想创建一个面板,然后告诉面板要运行的命令。
您似乎只是缺少 splitw
或 split-window
:
uuid="$(uuidgen)"
tmux new -d -s "$uuid"
tmux splitw -h -t "${uuid}:0.0"
tmux send-keys -t "${uuid}.0" "tsc -w" ENTER
tmux send-keys -t "${uuid}.1" "nodemon" ENTER
tmux a -t "$uuid"
Here's the tmux man page on splitw
:
split-window [-bdfhIvP] [-c start-directory] [-e environment] [-l size]
[-t target-pane] [shell-command] [-F format]
(alias: splitw)
Create a new pane by splitting target-pane: -h does a horizon‐
tal split and -v a vertical split; if neither is specified, -v
is assumed. The -l option specifies the size of the new pane
in lines (for vertical split) or in columns (for horizontal
split); size may be followed by ‘%’ to specify a percentage of
the available space. The -b option causes the new pane to be
created to the left of or above target-pane. The -f option
creates a new pane spanning the full window height (with -h) or
full window width (with -v), instead of splitting the active
pane.
An empty shell-command ('') will create a pane with no command
running in it. Output can be sent to such a pane with the
display-message command. The -I flag (if shell-command is not
specified or empty) will create an empty pane and forward any
output from stdin to it. For example:
$ make 2>&1|tmux splitw -dI &
All other options have the same meaning as for the new-window
command.
我想使用 tmux 在终端 window 中并排启动 2 个窗格:
tmux \
--vertical-pane='tsc -w' \
--vertical-pane='nodemon --watch' \
虽然我认为很有可能做到,但很难通过文档弄清楚如何做到这一点。
我想创建一个面板,然后告诉面板要运行的命令。
您似乎只是缺少 splitw
或 split-window
:
uuid="$(uuidgen)"
tmux new -d -s "$uuid"
tmux splitw -h -t "${uuid}:0.0"
tmux send-keys -t "${uuid}.0" "tsc -w" ENTER
tmux send-keys -t "${uuid}.1" "nodemon" ENTER
tmux a -t "$uuid"
Here's the tmux man page on splitw
:
split-window [-bdfhIvP] [-c start-directory] [-e environment] [-l size] [-t target-pane] [shell-command] [-F format] (alias: splitw) Create a new pane by splitting target-pane: -h does a horizon‐ tal split and -v a vertical split; if neither is specified, -v is assumed. The -l option specifies the size of the new pane in lines (for vertical split) or in columns (for horizontal split); size may be followed by ‘%’ to specify a percentage of the available space. The -b option causes the new pane to be created to the left of or above target-pane. The -f option creates a new pane spanning the full window height (with -h) or full window width (with -v), instead of splitting the active pane. An empty shell-command ('') will create a pane with no command running in it. Output can be sent to such a pane with the display-message command. The -I flag (if shell-command is not specified or empty) will create an empty pane and forward any output from stdin to it. For example: $ make 2>&1|tmux splitw -dI & All other options have the same meaning as for the new-window command.