An emacs
-inspired configuration of tmux
.
hmux
is an emacs
-inspired configuration of tmux
that also comes along with a few helpful bash functions to make tmux
more accessible.
While tmux
is not nearly as customizable as emacs
, tmux
does come with a surprising amount of customizable variables, hooks and bindings. The C-h
help prefix key should come in handy for anyone who wants to play around with their tmux
config.
If you use vim
or another editor and want to setup an easy-to-use tmux
configuration, hmux
's .tmux.conf file should be good a starting place to begin switching over useful tmux
bindings to your familiar keys.
git clone https://github.com/zhammer/hmux.git ~/.tmux.d ; ~/.tmux.d/install.sh
should be all you need to install hmux
and be able to pull from and push to github. This will clone hmux
into ~/.tmux.d
and create a symlink linking ~/.tmux.conf -> ~/.tmux.d/.tmux.conf
. The install.sh script will rename any current ~/.tmux.conf
file to ~/.tmux.conf.old.{timestamp}
so you don't lose old configurations.
You can also just clone the hmux
repo and hard copy hmux/.tmux.conf
to ~/.tmux.conf
if you don't want to setup ~/.tmux.d
and the symlinking, though it'll be harder to pull in github updates and you won't have a centralized, easy-to-access tmux
directory.
C-x-
global prefix key- In
hmux
, the defaulttmux
prefix key is switched fromC-b
toC-x
to match the prefix key ofemacs
. - (This means that using
emacs
in the shell requires an extraC-x
to send the prefix key toemacs
, though I dont know many people who useemacs
in-nw
mode. If this is an issue, you canset -g prefix
to another key.)
- In
C-h-
help prefix key- Prefix command for accessing information on active
tmux
key bindings and environment variables as well astmux
man-page documentation. C-h-?
for more info (experimental)
- Prefix command for accessing information on active
C-x 0
delete current pane- Delete the current pane. Fails if there is only one pane in the current window.
C-x 1
delete other panes in window- Delete all panes in the current window besides the active pane.
C-x 2
split pane below- Split the current pane vertically so that the new pane below is in the current pane's directory.
C-x 3
split pane right- Split the current pane horizontally so that the new pane to the right is in the current pane's directory.
C-x k
kill pane (y/n)M-x AND M-:
command prompt- Again, this conflicts with the
emacs
bindings if running in-nw
mode. You can useprefix M-x
andprefix M-:
to sendM-x
andM-:
toemacs
in shell. If inconvenient, I recommend changing these bindings.
- Again, this conflicts with the
C-x g
magit-lite- If inside a git repo, view the colorized git diff and status in a new window.
C-x r
re-source ~/.tmux.conf fileM-[
copy modeM-]
paste bufferC-x M-(Up|Down|Left|Right)
quick resizeM-T
open new window in ~/.tmux.dC-x Y
toggle sYnchronized-panes- When
synchronized-panes
is on, tmux will mirror keyboard input to all panes in the active window.
- When
C-x a
monitor-activity- When
monitor-activity
is on, windows in a session that have updated will display as highlighted in the status bar. (This behavior can be customized, see: thevisual-activity
window option.)
- When
C-b [0-9]
switch to window[0-9]
- (
hmux
'semacs
bindings overwrite some of the defaultC-x 0-9
switch to window bindings)
- (
C-x b
choose-buffer- All text saved to clipboard iin tmux is saved to an
emacs
-style kill-ring
- All text saved to clipboard iin tmux is saved to an
C-x W
rename-window
C-x s
choose session- Open the list of active sessions in an interactive pane
- tmux command:
choose-tree -s
C-x z
zoom pane- 'Zoom in' on the current pane, making it full screen until the
C-x z
is entered again - tmux command:
resize-pane -Z
- 'Zoom in' on the current pane, making it full screen until the
C-x C-o
rotate window- Rotate panes in the window
- tmux command:
rotate-window
Bash functions (tx.sh)
tx ls
- List all sessions on the default tmux server (
tmux ls
).
- List all sessions on the default tmux server (
tx {session_name}
- If called from outside a tmux client:
- Attach to
{session_name}
if it exists, otherwise create a new session called{session_name}
and attach to it.
- Attach to
- If called from inside a tmux client:
- Switch to
{session_name}
if it exists, otherwise print an error message.
- Switch to
- If called from outside a tmux client:
txk {session_name}
- Kill
{session_name}
.
- Kill
I read Brian Hogan's tmux 2 reference book in one afternoon at work after I'd spent a day juggling 5 shell windows to simultaneously start/stop a service, read its logs and run scripts on its data. The next day I was doing the same thing -- albeit a lot more easily -- in tmux
. tmux 2 is a great book and a really quick read.
Overall, tmux
is a great tool; the only major hurdle is the key bindings which are not always super convenient. Hopefully hmux
can make that transition easier.