Tmux: Difference between revisions
From charlesreid1
| Line 6: | Line 6: | ||
* Add more vim-like keyboard shortcuts to navigate between panels | * Add more vim-like keyboard shortcuts to navigate between panels | ||
* Create scripts and/or keyboard shortcuts that apply a certain session template (resizes panes, etc.) | * Create scripts and/or keyboard shortcuts that apply a certain session template (resizes panes, etc.) | ||
===Vim shortcuts in tmux config file=== | |||
<pre> | |||
# vi is good | |||
setw -g mode-keys vi | |||
</pre> | |||
===Add more vim-like keyboard shortcuts=== | |||
<pre> | |||
</pre> | |||
===Add scripts or keyboard shortcuts for session templates=== | |||
The following file should be stashed in your home dir next to your tmux config file (or anywhere else that's convenient). | |||
This is a tmux file that defines a particular session arrangement. This session arrangement is fairly simple, it is a top-bottom horizontal split, with the bottom window taking up about 20% of the space and with the top window having the "vim" command run in it. | |||
<code>~/.tmux.session1</code> | |||
<pre> | |||
# https://stackoverflow.com/a/5753059 | |||
new-session -A -s dev -n dev | |||
send-keys 'vim' C-m | |||
split-window -v -p 20 | |||
select-pane -t 1 | |||
</pre> | |||
Now, you can set a tmux keyboard shortcut to source this file when the keyboard shortcut is triggered. This will run these commands and set up a new tmux session called "dev" that has the specified configuration. | |||
To bind this to the "s" key, as in Control-A then s to apply this panel configuration, add this to <code>~/.tmux.conf</code>: | |||
<pre> | |||
# Set up easy go-to sessions with shortcuts | |||
bind s source-file ~/.tmux.session1 | |||
</pre> | |||
==git.charlesreid1.com== | ==git.charlesreid1.com== | ||
Revision as of 20:40, 13 August 2019
Vim Integration
Tmux and vim integration:
- Set up vim keyboard shortcuts in the tmux config file
- Add more vim-like keyboard shortcuts to navigate between panels
- Create scripts and/or keyboard shortcuts that apply a certain session template (resizes panes, etc.)
Vim shortcuts in tmux config file
# vi is good setw -g mode-keys vi
Add more vim-like keyboard shortcuts
Add scripts or keyboard shortcuts for session templates
The following file should be stashed in your home dir next to your tmux config file (or anywhere else that's convenient).
This is a tmux file that defines a particular session arrangement. This session arrangement is fairly simple, it is a top-bottom horizontal split, with the bottom window taking up about 20% of the space and with the top window having the "vim" command run in it.
~/.tmux.session1
# https://stackoverflow.com/a/5753059 new-session -A -s dev -n dev send-keys 'vim' C-m split-window -v -p 20 select-pane -t 1
Now, you can set a tmux keyboard shortcut to source this file when the keyboard shortcut is triggered. This will run these commands and set up a new tmux session called "dev" that has the specified configuration.
To bind this to the "s" key, as in Control-A then s to apply this panel configuration, add this to ~/.tmux.conf:
# Set up easy go-to sessions with shortcuts bind s source-file ~/.tmux.session1
git.charlesreid1.com
my tmux configuration file is here: https://git.charlesreid1.com/dotfiles/debian/src/branch/master/dotfiles/.tmux.conf
Alternatively: https://github.com/charlesreid1/mac-dotfiles/blob/master/.tmux.conf
Links
Tmux cheat sheet: https://gist.github.com/afair/3489752
Why tmux: http://dominik.honnef.co/posts/2010/10/why_you_should_try_tmux_instead_of_screen/