Reputation: 467
I often have two panes on a tmux window, left pane to view source code, and right pane to cmake .. && make
. I want to change to the source code directory quickly and mkdir build && cd build
on right pane, but the build directory may not exist, if so, create and cd build directory if non-exist ? how to do this using tmux inner command or other advanced way ?
the following is my temporary and coarse approach, but It's not correct.
bind o kill-pane \; split-window -h -c '#{pane_current_path}/build'
Upvotes: 0
Views: 532
Reputation: 467
send-keys
is the magic.
bind o kill-pane \; split-window -h -c '#{pane_current_path}' \;\
send-keys -l 'cmd build' \; send-keys 'C-m' 'C-l'
send-keys -l
stands for literal.
C-m
to enter.
C-l
to clear the screen.
P.S. cmd build
is my own custom command works the same as mkdir build && cd build
.
Upvotes: 1