Last active
August 8, 2024 13:50
-
-
Save misaelvillaverde/e34c5e0893c34ddc3b47dd71429ccf84 to your computer and use it in GitHub Desktop.
tmux conf
This file contains hidden or 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
| # set-option -sa terminal-overrides ",xterm-kitty:RGB" | |
| # set -g default-terminal "tmux-256color" | |
| set -g default-terminal "screen-256color" | |
| # tell Tmux that outside terminal supports true color | |
| set -ga terminal-overrides ",xterm-256color*:Tc" | |
| # Undercurl, taken from: https://github.com/folke/lsp-colors.nvim | |
| set -g default-terminal "${TERM}" | |
| set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support | |
| set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0 | |
| # Fix copy and paste: `brew install reattach-to-user-namespace` | |
| # if-shell 'test "$(uname -s)" = Darwin' 'set-option -g default-command "exec reattach-to-user-namespace -l zsh"' | |
| # start window numbers at 1 to match keyboard order with tmux window order | |
| set -g base-index 1 | |
| # start pane indexing at 1 for tmuxinator | |
| set-window-option -g pane-base-index 1 | |
| # renumber windows sequentially after closing any of them | |
| set -g renumber-windows on | |
| # Faster escape sequences (default is 500ms). | |
| # This helps when exiting insert mode in Vim: http://superuser.com/a/252717/65504 | |
| set -s escape-time 50 | |
| # Bigger scrollback buffer | |
| set -g history-limit 10000 | |
| # Neovim says it needs this | |
| set-option -g focus-events on | |
| # Smart pane switching with awareness of Vim splits. | |
| # See: https://github.com/christoomey/vim-tmux-navigator | |
| is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | |
| | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" | |
| bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' | |
| bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' | |
| bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' | |
| bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' | |
| tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' | |
| if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ | |
| "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" | |
| if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ | |
| "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" | |
| bind-key -T copy-mode-vi 'C-h' select-pane -L | |
| bind-key -T copy-mode-vi 'C-j' select-pane -D | |
| bind-key -T copy-mode-vi 'C-k' select-pane -U | |
| bind-key -T copy-mode-vi 'C-l' select-pane -R | |
| bind-key -T copy-mode-vi 'C-\' select-pane -l | |
| # Resize the panes with prefix+arrow keys | |
| bind Up resize-pane -U 5 | |
| bind Down resize-pane -D 5 | |
| bind Left resize-pane -L 5 | |
| bind Right resize-pane -R 5 | |
| # Rebind 'clear screen' to <prefix>+c-l | |
| bind C-l send-keys 'C-l' | |
| # Rebind spit and new-window commands to use current path | |
| bind '"' split-window -c "#{pane_current_path}" | |
| bind % split-window -h -c "#{pane_current_path}" | |
| bind c new-window -c "#{pane_current_path}" | |
| # Bind C-s to fuzzy switch session | |
| bind -n C-s \ | |
| split-window -l 10 'session=$(tmux list-sessions -F "#{session_name}" | fzf --query="$1" --select-1 --exit-0) && tmux switch-client -t "$session"' \; | |
| # Style status bar | |
| set -g status-style fg=white,bg=black | |
| set -g window-status-current-style fg=green,bg=black | |
| set -g pane-active-border-style fg=green,bg=black | |
| set -g window-status-format " #I:#W#F " | |
| set -g window-status-current-format " #I:#W#F " | |
| set -g window-status-current-style bg=green,fg=black | |
| set -g window-status-activity-style bg=black,fg=yellow | |
| set -g window-status-separator "" | |
| set -g status-justify centre | |
| # Use vim keybindings in copy mode | |
| setw -g mode-keys vi | |
| # Setup 'v' to begin selection as in Vim | |
| bind-key -T copy-mode-vi v send -X begin-selection | |
| # Setup 'y' to copy selection as in Vim | |
| # Use reattach-to-user-namespace with pbcopy on OS X | |
| # Use xclip on Linux | |
| # set -g set-clipboard off | |
| # if-shell 'test "$(uname -s)" = Darwin' 'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy 2> /dev/null"' 'bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -i -selection clipboard"' | |
| # Fix for ssh-agent (http://fredkelly.net/articles/2014/10/19/developing_on_yosemite.html) | |
| set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_C" | |
| # Mousemode | |
| # Toggle mouse on with ^B m | |
| bind m \ | |
| set -g mouse on \;\ | |
| display 'Mouse Mode: ON' | |
| # Toggle mouse off with ^B M | |
| bind M \ | |
| set -g mouse off \;\ | |
| display 'Mouse Mode: OFF' | |
| # Move current window to the left with Ctrl-Shift-Left | |
| bind-key -n C-S-Left swap-window -t -1 | |
| # Move current window to the right with Ctrl-Shift-Right | |
| bind-key -n C-S-Right swap-window -t +1 | |
| # Open a "test" split-window at the bottom | |
| bind t split-window -f -l 15 -c "#{pane_current_path}" | |
| # Open a "test" split-window at the right | |
| bind T split-window -h -f -p 35 -c "#{pane_current_path}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment