Created
May 28, 2024 10:03
-
-
Save Leenuus/7eff63d77afe46839e96f4853bbdd103 to your computer and use it in GitHub Desktop.
My tmux configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: make image preview in kitty work | |
set -g allow-passthrough on | |
# NOTE: prefix | |
set -g prefix M-a | |
bind M-a send-prefix | |
unbind C-b | |
set -g status-style fg=default,fg=default | |
# set -g base-index 1 | |
# set -g pane-base-index 1 | |
set -g mouse on | |
set -g cursor-style bar | |
# https://superuser.com/a/1809494/1824899 | |
set -sg escape-time 5 | |
set -g history-limit 50000 | |
set -g display-time 4000 | |
set -g status-interval 5 | |
set -g status-keys emacs | |
set -g focus-events on | |
set-window-option -g aggressive-resize on | |
set-window-option -g mode-keys vi | |
# NOTE: status bar look | |
set -g status-position top | |
set -g status-left '#{?client_prefix,#[bg=red],} #S ' | |
set -g status-right '' | |
set-window-option -g window-status-format ' #{?window_zoomed_flag,,} #I: #W ' | |
set-window-option -g window-status-current-format '#{?window_active,#[bg=yellow],} #{?window_zoomed_flag,,} #I: #W ' | |
# Make colorscheme in neovim works | |
# See relevant question on stackoverflow: https://stackoverflow.com/a/60313682 | |
# This works for ArchLinux, alacritty | |
set-option -ga terminal-overrides ",xterm-256color:Tc" | |
# Quick refresh of tmux config | |
unbind M-s | |
bind M-s source-file ~/.config/tmux/tmux.conf | |
# Session management | |
unbind s | |
unbind x | |
bind M-q switchc -p # prefix M-q switch to previous session | |
bind M-e switchc -n # prefix M-e switch to next session | |
bind M-t new-session | |
unbind r | |
bind r command-prompt -I "" { rename-session "%%" } # prefix r to rename session | |
bind M-r command-prompt -I "" { rename-session "%%" } # prefix r to rename session | |
bind x kill-session | |
# Windows Management | |
bind p resize-pane -Z #zoom | |
bind d split-window -h -c '#{pane_current_path}' # vertical split | |
bind a split-window -v -c '#{pane_current_path}' # horizontal split | |
bind x set-option status # toggle status bar | |
unbind % | |
unbind 0 | |
unbind 1 | |
unbind 2 | |
unbind 3 | |
unbind 4 | |
unbind 5 | |
unbind 6 | |
unbind 7 | |
unbind 8 | |
unbind 9 | |
bind \\ split-window -h -c '#{pane_current_path}' # vertical split, semantic keybinding!!! | |
bind D detach-client | |
unbind '"' | |
bind - split-window -v -c '#{pane_current_path}' # horizontal split, semantic keybinding!!! | |
bind -r J resize-pane -D 4 | |
bind -r K resize-pane -U 4 | |
bind -r L resize-pane -R 4 | |
bind -r H resize-pane -L 4 | |
bind -r m resize-pane -Z # maximize/unmaximize pane | |
bind h select-pane -L # select pane on left | |
bind j select-pane -D # select pane on bottom | |
bind k select-pane -U # select pane on top | |
bind l select-pane -R # select pane on right | |
bind -n M-t new-window -c "#{pane_current_path}" | |
bind -n M-q previous-window | |
bind -n M-e next-window | |
bind f display-popup -E -x20% -y20% -h40% -w80% "$HOME/bin/tmux-window" | |
# NOTE: popup for editing oldfiles | |
bind s display-popup -E -x20% -y20% -h80% -w80% nvim | |
bind -n M-w kill-pane | |
# bind -n M-0 kill-pane -a | |
bind -n M-r command-prompt -I "#W" { rename-window "%%" } | |
# Copy mode like vim | |
bind -n M-x copy-mode | |
# NOTE: if programs specified in `TMUX_YANK_NOT_CANCEL_PAT` are running in current pane | |
# don't exit copy-mode after yanking, otherwise quit copy mode after yanking | |
bind -T copy-mode-vi 'y' if-shell "$HOME/bin/tmux-yank #{pane_tty}" { | |
send-keys -X copy-selection | |
} { | |
send-keys -X copy-selection-and-cancel | |
} | |
bind -T copy-mode-vi 'Y' send-keys -X copy-selection-and-cancel | |
unbind -T copy-mode-vi H | |
unbind -T copy-mode-vi L | |
unbind -T copy-mode-vi J | |
unbind -T copy-mode-vi K | |
unbind -T copy-mode-vi MouseDragEnd1Pane | |
unbind -T copy-mode-vi C-v | |
bind -T copy-mode-vi 'v' send -X begin-selection | |
bind -T copy-mode-vi 'H' send -X start-of-line | |
bind -T copy-mode-vi 'L' send -X end-of-line | |
bind -T copy-mode-vi 'K' send -X halfpage-up | |
bind -T copy-mode-vi 'J' send -X halfpage-down | |
bind -T copy-mode-vi Escape send -X clear-selection | |
bind -T copy-mode-vi 'i' send -X cancel | |
bind -T copy-mode-vi 'a' send -X cancel | |
bind -T copy-mode-vi 'q' send -X cancel | |
bind -T copy-mode-vi ? command-prompt -T search -p "(search down)" { send-keys -X search-forward "%%" } | |
bind -T copy-mode-vi / command-prompt -T search -p "(search up)" { send-keys -X search-backward "%%" } | |
bind-key -n 'C-j' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } } | |
bind-key -n 'C-k' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } } | |
bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D } | |
bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U } | |
bind-key -n 'C-h' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-h } { | |
if-shell -F '#{pane_at_left}' { previous-window } { if-shell '[[ #W =~ nnn ]]' { previous-window } { select-pane -L }}} | |
bind-key -n 'C-l' if-shell "$HOME/bin/tmux-navigator #{pane_tty} #W" { send-keys C-l } { | |
if-shell -F '#{pane_at_right}' { next-window } { if-shell '[[ #W =~ nnn ]]' { next-window } { select-pane -R }}} | |
bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' { previous-window } { if-shell '[[ #W =~ nnn ]]' { previous-window } { select-pane -L }} | |
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' { next-window } { if-shell '[[ #W =~ nnn ]]' { next-window } { select-pane -R }} | |
bind C-l send-keys 'C-l' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment