
Configuration
Edit $HOME/.tmux.conf.
Keyboard shortcut
-
Reload
.tmux.conf
Reload configuration file withCtrl-b r:bind-key r source ~/.tmux.conf
-
Last active window
By default, you need to pressCtrl-b lto go to the last window. For faster typing, you can set it toCtrl-b-b:bind-key C-b last-window -
Switch pane
By default, shortcut for switch pane isCtrl-b ArrrowKey, add shortcutAlt-ArrowKeyfor faster switching:bind -n M-Left select-pane -L bind -n M-Right select-pane -R bind -n M-Up select-pane -U bind -n M-Down select-pane -D
Theming
Make tmux status bar clean.
set -g status-justify left
set -g status-style "bg=colour0"
set -ag status-style "fg=colour7"
set -g status-left ''
set -g status-right "'#H' #[fg=colour15]#(date +"%H:%M") "
set -ag status-right "#[fg=colour15]#(date +"%d/%m")#[fg=colour8] #(date +"%Y") "
set -g window-status-current-format "#[fg=colour15] #F#I:#W#F "
set -g window-status-format "#[fg=colour8] #F#I:#W#F "
set -g default-terminal "screen-256color"Common use
| Command/Shortcut | Action |
|---|---|
| tmux | Start new session |
| tmux new -s saymyname | Start new session with name saymyname |
| Ctrl-b ? | See all keybindings |
| Ctrl-b c | Create new window |
| Ctrl-b , | Rename window |
| Ctrl-b 1 | Go to window 1 |
| Ctrl-b-b | Go to the last-active window |
| Ctrl-b " | Split window horizontally |
| Ctrl-b % | Split window vertically |
| Ctrl-b ArrowKey, Alt-ArrowKey | Switch pane |
| Ctrl-b ESC-[1-5] | Change panel layout to style 1 to 5 |
| Ctrl-b z | Toggle zoom for pane |
| Ctrl-b [ | Change to scroll mode ('q' to quit) |
| Ctrl-b d | Detach current session |
| tmux ls | Show all sessions |
| tmux a | Attach last session |
| tmux a -t saymyname | Attach session with name saymyname |
Example ~/.tmux.conf
bind-key C-b last-window
# unbind key for helix
unbind-key -T prefix /
# reload tmux conf
bind-key r source ~/.tmux.conf
# Switch pane with Alt-Arrow
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Support true color
set -ga terminal-overrides ",*256col*:Tc"
# set -g default-terminal "tmux-256color"
# Disable escape timeout for helix
set -sg escape-time 10
# Theme
set -g status-justify left
## COLORSCHEME: gruvbox dark (medium)
set-option -g status "on"
# default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# pane border
set-option -g pane-active-border-style fg=colour250 #fg2
set-option -g pane-border-style fg=colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# pane number display
set-option -g display-panes-active-colour colour250 #fg2
set-option -g display-panes-colour colour237 #bg1
# clock
set-window-option -g clock-mode-colour colour109 #blue
# bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-justify "left"
set-option -g status-left-style none
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h "
set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]"
Comments