Tmux for mere mortals

Tmux has liberated me from tiling window mangers. Not that I didn’t like those, but I occasionally have to work with macOS or default GNOME setups. And over the...
Tmux for mere mortals

Tmux has liberated me from tiling window mangers. Now not that I didn’t like these, but I as soon as quickly must work with macOS or default GNOME setups. And over the years I realised that I handiest need a terminal multiplexor to attain terminal tiling for me, the comfort of the windows are factual magnificent to be corpulent-camouflage in separate workspaces.

So, I finished up doing 80% of my work in terminals with tmux. Nonetheless, the prefix factor? Pardonnez-moi, but usability issues. Urgent a chorded prefix hotkey handiest to press one other chorded hotkey to invent a single motion is certain nonsense.

With this in mind, I determined to customise my tmux to expend handiest easy chorded hotkeys with out a prefix for loads of basic actions, and to assemble them easy to set in mind. Additionally, my honest used to be now not to override something in the default tmux configuration in explain to expend default tmux as well, if I’ve to (i.e. when ssh’ed to a pair distant server). Finally, I needed it to be associated in German/US keyboards, as well to work for MacBooks and long-established laptops.

Right here’s what I came up with:

  • Mod+1..9: switch windows from 1 to 9
  • Mod+, and Mod+.: switch to next/prev windows
  • Mod+HJKL or arrows: switch between panes
  • Mod+N: manufacture original window
  • Mod+F: toggle corpulent-camouflage
  • Mod+V: spoil up vertically
  • Mod+B: spoil up horizontally (“bisect”)
  • Mod+X: shut pane
  • Mod+/: enter reproduction and scroll mode

Intuitive? Now, same hotkeys with Shift key are former to regulate things:

  • Mod+< and Mod+>: circulation latest window to the left/simply
  • Mod+Shift+HJKL or arrows: circulation pane to the left/simply/up/down
  • Mod+Shift+X: shut window
  • Mod+Shift+R: rename window

That’s somewhat noteworthy the total lot I ever wanted from tmux. For other, less frequent actions I accept to expend the default bindings, every infrequently.

Additionally, I’d like tmux to expend my primary clipboard on all programs, so that I’d handiest must reproduction textual snarl with my mouse or keyboard need. Resizing panes will more than seemingly be usable with a mouse.

As for the space bar, I’m now not a gargantuan fan of being overloaded with knowledge, so I handiest repeat window names there, or in the case then window has handiest an originate shell – latest itemizing title.

Nothing else.

Right here’s the tmux.conf (otherwise you may maybe maybe well well presumably constantly have a have a examine my dotfiles for a more recent model:

space-choice -g default-terminal camouflage-256coloration
space -g ancient past-restrict 10000
space -g contaminated-index 1
space-choice -g renumber-windows on
space -s spoil out-time 0
bind-key -n M-n original-window -c "#{pane_current_path}"
bind-key -n M-1 dispose of-window -t :1
bind-key -n M-2 dispose of-window -t :2
bind-key -n M-3 dispose of-window -t :3
bind-key -n M-4 dispose of-window -t :4
bind-key -n M-5 dispose of-window -t :5
bind-key -n M-6 dispose of-window -t :6
bind-key -n M-7 dispose of-window -t :7
bind-key -n M-8 dispose of-window -t :8
bind-key -n M-9 dispose of-window -t :9
bind-key -n M-0 dispose of-window -t :0
bind-key -n M-. dispose of-window -n
bind-key -n M-, dispose of-window -p
bind-key -n M-< swap-window -t -1
bind-key -n M-> swap-window -t +1
bind-key -n M-X verify-sooner than "extinguish-window"
bind-key -n M-v spoil up-window -h -c "#{pane_current_path}"
bind-key -n M-b spoil up-window -v -c "#{pane_current_path}"
bind-key -n M-R uncover-suggested -I "" "rename-window '%%'"
bind-key -n M-f resize-pane -Z
bind-key -n M-h dispose of-pane -L
bind-key -n M-l dispose of-pane -R
bind-key -n M-k dispose of-pane -U
bind-key -n M-j dispose of-pane -D
bind-key -n M-Left dispose of-pane -L
bind-key -n M-Correct dispose of-pane -R
bind-key -n M-Up dispose of-pane -U
bind-key -n M-Down dispose of-pane -D
bind-key -n "M-H" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -L; tmux swap-pane -t $dilapidated'
bind-key -n "M-J" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -D; tmux swap-pane -t $dilapidated'
bind-key -n "M-Ok" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -U; tmux swap-pane -t $dilapidated'
bind-key -n "M-L" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -R; tmux swap-pane -t $dilapidated'
bind-key -n "M-S-Left" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -L; tmux swap-pane -t $dilapidated'
bind-key -n "M-S-Down" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -D; tmux swap-pane -t $dilapidated'
bind-key -n "M-S-Up" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -U; tmux swap-pane -t $dilapidated'
bind-key -n "M-S-Correct" race-shell 'dilapidated=`tmux show -p "#{pane_index}"`; tmux dispose of-pane -R; tmux swap-pane -t $dilapidated'
bind-key -n M-x verify-sooner than "extinguish-pane"
bind-key -n M-/ reproduction-mode

# Linux system clipboard
bind -T reproduction-mode-vi Enter ship-keys -X reproduction-pipe-and-abolish "xclip -in -need clipboard"
bind-key -T reproduction-mode-vi MouseDragEnd1Pane ship -X reproduction-pipe-and-abolish "xclip -in -need clipboard"

# macOS system clipboard
#bind -T reproduction-mode-vi Enter ship-keys -X reproduction-pipe-and-abolish "pbcopy"
#bind-key -T reproduction-mode-vi MouseDragEnd1Pane ship -X reproduction-pipe-and-abolish "pbcopy"

space -g mouse on
space-choice -g space-keys vi
space-choice -g space-titles on
space-choice -g space-titles-string 'tmux - #W'
space -g bell-motion any
space-choice -g visual-bell off
space-choice -g space-clipboard off
setw -g mode-keys vi
setw -g display screen-exercise on
space -g visual-exercise on
space -g space-style fg=coloration15
space -g space-define centre
space -g space-left ''
space -g space-simply ''
space -g space-interval 1
space -g message-style fg=colour0,bg=colour3
setw -g window-space-bell-style fg=colour1
setw -g window-space-latest-style fg=yellow,audacious
setw -g window-space-style fg=coloration250
setw -g window-space-latest-format ' #{?#{==:#W,#{b:SHELL}},#{b:pane_current_path},#W} '
setw -g window-space-format ' #{?#{==:#W,#{b:SHELL}},#{b:pane_current_path},#W} '
# For older tmux:
#setw -g window-space-format ' #W '
#setw -g window-space-latest-format ' #W '

Now tmux feels like a typical desktop app and in truth boosts the productiveness in the terminal. What attain you imagine?

Apr 25, 2020

like
 
tweet
 
rss
 
@me
 
me

Be taught Extra

Categories
Internet of Things
No Comment

Leave a Reply

RELATED BY