Files
dotfiles/tmux/tmux.conf
T
2025-09-03 14:23:55 +02:00

214 lines
7.1 KiB
Bash

######################
### SETTINGS ###
######################
# escape time
set -sg escape-time 0
setw -g mode-keys vi
set -g mouse on
# clipboard control
set -g set-clipboard on
set -g allow-passthrough
set -g history-limit 20000
set -g focus-events on
# screen colors
set -as terminal-features ",gnome*:RGB"
# Start with index 1
set -g base-index 1
setw -g pane-base-index 1
# colors
fg_active_pane="default"
fg_inactive_pane="color242"
fg_active_window="color0"
bg_active_window="color252"
bg_highlight="red"
# pane title
ps_pid='#(pgrep -P "#{pane_pid}" | tr "\n" " ")'
cmd='#(ps --no-headers -o args $(pgrep -P "#{pane_pid}"))'
# cmd='#(ps --no-headers -t #{pane_tty} -o args -O-c | tr "\n" " ")'
setw -g pane-border-status top
setw -g pane-border-format " #{pane_current_path} #{=/-20/…:pane_current_command} ${ps_pid}[${cmd}] #{?alternate_on,<Alt Mode> ,}"
set -g pane-border-style "fg=${fg_inactive_pane}"
set -g pane-active-border-style "fg=${fg_active_pane}"
# status line
default_color="#[bg=default,fg=default,bold]"
indicator=" η "
window_status_format=' #I:#W '
expanded_icon='󰊓 '
# Setting the options in tmux
set -g status-position "bottom"
set -g status-style bg=default,fg=default
set -g status-justify "centre"
set -g status-left "${default_color}#{?client_prefix,,${indicator}}#[bg=${bg_highlight},fg=${fg_active_window},bold]#{?client_prefix,${indicator},}${default_color}"
set -g status-right "session #S - %H:%M %d/%m/%y"
set -g window-status-format " ${window_status_format}#{?window_zoomed_flag,󰊓 ,}"
set -g window-status-current-format "#[fg=${bg_active_window}]#[bg=${bg_active_window},fg=${fg_active_window}]${window_status_format}#{?window_zoomed_flag,${expanded_icon},}#[fg=${bg_active_window},bg=default]"
# Automatically set window title
setw -g automatic-rename on
set -g set-titles on
######################
### KEYBINDS ###
######################
# Config that is very close to a i3 window manager's keybinding.
# Set new prefix
# Note : you can press super key by set M.
# (tested with tty only)
set -g prefix M-a
bind M-a send-prefix
# First remove *all* keybindings
unbind -a
# Basic bindings
bind ? list-keys
bind d detach-client
bind D choose-client
bind : command-prompt
bind '~' show-messages
# Copy mode
bind c copy-mode
# clipboard control
bind p paste-buffer
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
bind -T copy-mode-vi r send-keys -X rectangle-toggle
bind -T copy-mode-vi Escape send-keys -X cancel
bind -T copy-mode-vi q send-keys -X clear-selection
bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection primary -filter | xclip -selection clipboard"
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection primary -filter | xclip -selection clipboard"
# Rename window
bind , command-prompt "rename-window %%"
bind . command-prompt "rename-session %%"
# Clock mode
bind t clock-mode
# Show pane numbers
bind i display-panes
# Config Reloads
bind r source-file ~/.config/tmux/tmux.conf \; refresh-client \; display-message "Config reloaded"
# zoom control
bind -n M-o resize-pane -Z
# get urls
bind u run "tmux popup -E -b double -w 100% -h 100% sh -c 'tmux capture-pane -Jp | urlscan -d' "
# split panes using | and -, make sure they open in the same path
bind v split-window -h -c "#{pane_current_path}"
bind s split-window -v -c "#{pane_current_path}"
bind V split-window -fh -c "#{pane_current_path}"
bind S split-window -fv -c "#{pane_current_path}"
# Change layouts
bind o rotate-window
bind Space next-layout
bind = select-layout even-horizontal
bind + select-layout main-horizontal
bind - select-layout even-vertical
bind _ select-layout main-vertical
bind / select-layout tiled
bind K swap-pane -d -t "{up-of}"
bind J swap-pane -d -t "{down-of}"
bind H swap-pane -d -t "{left-of}"
bind L swap-pane -d -t "{right-of}"
# Choose
bind w choose-tree
# Change current pane to next window
bind ` break-pane
bind 1 if 'tmux join-pane -t :1 -h' '' 'new-window -d -t :1; join-pane -t :1'
bind 2 if 'tmux join-pane -t :2 -h' '' 'new-window -d -t :2; join-pane -t :2'
bind 3 if 'tmux join-pane -t :3 -h' '' 'new-window -d -t :3; join-pane -t :3'
bind 4 if 'tmux join-pane -t :4 -h' '' 'new-window -d -t :4; join-pane -t :4'
bind 5 if 'tmux join-pane -t :5 -h' '' 'new-window -d -t :5; join-pane -t :5'
bind 6 if 'tmux join-pane -t :6 -h' '' 'new-window -d -t :6; join-pane -t :6'
bind 7 if 'tmux join-pane -t :7 -h' '' 'new-window -d -t :7; join-pane -t :7'
bind 8 if 'tmux join-pane -t :8 -h' '' 'new-window -d -t :8; join-pane -t :8'
bind 9 if 'tmux join-pane -t :9 -h' '' 'new-window -d -t :9; join-pane -t :9'
bind 0 if 'tmux join-pane -t :10 -h' '' 'new-window -d -t :10; join-pane -t :10 -h'
# move windows
bind m command-prompt -p "move window to:" "move-window -t '%%'"
bind F1 move-window -t :1
bind F2 move-window -t :2
bind F3 move-window -t :3
bind F4 move-window -t :4
bind F5 move-window -t :5
bind F6 move-window -t :6
bind F7 move-window -t :7
bind F8 move-window -t :8
bind F9 move-window -t :9
bind F10 move-window -t :10
# Switch windows alt+number
bind -n M-1 if-shell 'tmux select-window -t :1' '' 'new-window -t :1'
bind -n M-2 if-shell 'tmux select-window -t :2' '' 'new-window -t :2'
bind -n M-3 if-shell 'tmux select-window -t :3' '' 'new-window -t :3'
bind -n M-4 if-shell 'tmux select-window -t :4' '' 'new-window -t :4'
bind -n M-5 if-shell 'tmux select-window -t :5' '' 'new-window -t :5'
bind -n M-6 if-shell 'tmux select-window -t :6' '' 'new-window -t :6'
bind -n M-7 if-shell 'tmux select-window -t :7' '' 'new-window -t :7'
bind -n M-8 if-shell 'tmux select-window -t :8' '' 'new-window -t :8'
bind -n M-9 if-shell 'tmux select-window -t :9' '' 'new-window -t :9'
bind -n M-0 if-shell 'tmux select-window -t :10' '' 'new-window -t :10'
# Kill Selected Pane
bind q confirm-before -p "kill-pane #P? (y/n)" kill-pane
# clear selected pane
bind b send-keys -R \; clear-history \; send-keys Enter
######################
### PLUGINS ###
######################
# various plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'
######################
### PANE CONTROL ###
######################
set -g @plugin 'mrjones2014/smart-splits.nvim'
# Optional configurations with their default values if omitted:
set -g @smart-splits_no_wrap '' # to disable wrapping. (any value disables wrapping)
set -g @smart-splits_move_left_key 'M-h' # key-mapping for navigation.
set -g @smart-splits_move_down_key 'M-j' # --"--
set -g @smart-splits_move_up_key 'M-k' # --"--
set -g @smart-splits_move_right_key 'M-l' # --"--
set -g @smart-splits_resize_left_key 'C-h' # key-mapping for resizing.
set -g @smart-splits_resize_down_key 'C-j' # --"--
set -g @smart-splits_resize_up_key 'C-k' # --"--
set -g @smart-splits_resize_right_key 'C-l' # --"--
set -g @smart-splits_resize_step_size '3' # change the step-size for resizing.
######################
### KEEP AT BOTTOM ###
######################
run -b '~/.config/tmux/plugins/tpm/tpm'