# ______ # /_ __/___ ___ __ ___ __ # / / / __ `__ \/ / / / |/_/ # / / / / / / / / /_/ /> < # /_/ /_/ /_/ /_/\__,_/_/|_| # # Corey Smith # Tmux Configurations # corey@litteplummercreek.studio #------------------------------------------------------------------------------ # Configuration Notes #------------------------------------------------------------------------------ # # Tmux has shortened versions of some commands, the following are used: # set = set-option # setw = set-window-option # bind = bind-key # run = run-shell # set-environment -g TMUX_PLUGIN_MANAGER_PATH "$XDG_DATA_HOME/tmux/plugins" #------------------------------------------------------------------------------ # Set helper script path #------------------------------------------------------------------------------ # # This is where custom helper scripts need to be located for tmux # to utilize them. # script_path="$HOME/.config/tmux/scripts" #------------------------------------------------------------------------------ # Open windows and panes in current directory #------------------------------------------------------------------------------ # # By default Tmux opens new windows and panes in the user home directory, I # would prefer they open in the directory I am currently in since I am usually # working on a project and just need a new terminal window. # bind c new-window -c "#{pane_current_path}" bind '"' split-window -v -c "#{pane_current_path}" bind % split-window -h -c "#{pane_current_path}" #------------------------------------------------------------------------------ # Turn on mouse reporting for native scrolling #------------------------------------------------------------------------------ # # This allows tmux to scroll contents using the mouse scroll wheel. # set -g mouse on #------------------------------------------------------------------------------ # Speed up refresh rate #------------------------------------------------------------------------------ # # Using Gitmux is nicer with a faster response time, this speeds up how # quickly the Tmux status bar will refresh itself with new information. # set -g status-interval 1 #------------------------------------------------------------------------------ # Set Tmux 256 Colors #------------------------------------------------------------------------------ # # More colors! # set -g default-terminal 'tmux-256color' set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m' #------------------------------------------------------------------------------ # Set Focus Events On #------------------------------------------------------------------------------ # # Neovim :checkhealth recommends setting focus-events to on. What does it do? # set -g focus-events on #------------------------------------------------------------------------------ # Order sessions by name #------------------------------------------------------------------------------ # # s provides a list of open sessions, I find it easier to scan them # if they are ordered alphabetically ascending by name. # bind s choose-tree -ZsNO name #------------------------------------------------------------------------------ # Message Style #----------------------------------------------------------------------------- # # : # set -g message-style "bg=default, fg=#000000,bold" set -g message-command-style "bg=default, fg=#000000,bold" #------------------------------------------------------------------------------ # Set indexes to 1 instead of 0 #------------------------------------------------------------------------------ # # A lot of programming languages are zero indexed. But I'm not programming # when using Tmux. I am using an interface. I want lists to start from 1, # which coincidentally also matches the leftmost number key on my keyboard. # # Below, "panes" and "windows" are configured to start at 1. # # It is unfortunately not possible to start the session list from 1 yet. # set -g mode-style "bg=#3B82F6,fg=#FDFDFF" set -g renumber-windows on set -g base-index 1 setw -g pane-base-index 1 #------------------------------------------------------------------------------ # Status Bar #------------------------------------------------------------------------------ # # I prefer the Tmux Status Bar at the top because it clashes with Neovim's # Status Bar and Command Lines. I also prefer to think of Tmux's Status Bar # as a macOS style "Menu Bar for the command line". # set -g status-position top #------------------------------------------------------------------------------ # Status Bar Border #------------------------------------------------------------------------------ # # Move the status bar to the top and format it as an underline below the # status bar. Set the pane borders to a color that blends with Neovim's # Vertical and Horizontal Splits. # setw -g pane-border-status top setw -g pane-border-format '─' set -g pane-border-style "bg=default, fg=#A3A6AE" set -g pane-active-border-style "bg=default, fg=#A3A6AE" #------------------------------------------------------------------------------ # Popup #------------------------------------------------------------------------------ # # Settings for the Tmux Popup function # set -g popup-border-lines "double" set -g popup-border-style fg=black bind-key p display-popup -T ' Shell ' -d "#{pane_current_path}" bind-key s display-popup -E "tmux list-sessions -F '#{session_name}' | fzf --prompt='Select Tmux Session: ' | xargs -I {} tmux switch-client -t '{}'" #------------------------------------------------------------------------------ # Status Bar Information #------------------------------------------------------------------------------ # # The information displayed in the status bar. # gitmux_path="$HOME/.gitmux.conf" separator=" #[fg=#A3A6AE]│#[fg=#000000] " tmux_logo=" 󰙀 " session="#[bold]#S#[nobold]" # directory=" #(echo '#{pane_current_path}/' | sed 's|^$HOME|~|')" directory="#(${script_path}/ssh_aware_directory.sh '#{pane_current_path}')" # git_icon="${separator}#(${script_path}/get_git_hosting.sh '#{pane_current_path}') " # git_status="#[fg=#555555]#(gitmux -cfg ${gitmux_path} '#{pane_current_path}')#[fg=#000000]" date_time="%l:%M%p" status_color="fg=#000000, bg=default" window_status_format='  #[fg=#555555]#W#[fg=#000000]' window_status_current_format=' #[fg=#047857] #[fg=#000000]#[bold]#W#[nobold]' # Function to get the number of panes when zoomed pane_count="#(tmux list-panes -t '#{session_name}:#{window_index}' | wc -l | tr -d ' ')" # Function to indicate if the current window is zoomed zoomed_flag="#(if [ #{window_zoomed_flag} -eq 1 ]; then echo ' '; else echo ' '; fi)" set -g status-style "${status_color}" set -g status-justify right set -g status-left-length 300 set -g window-status-format "${window_status_format}" set -g window-status-current-format "${window_status_current_format}" set -g status-left "${tmux_logo}${session}${separator}${directory}${separator}" set -g status-right "${separator}${zoomed_flag}${pane_count} " #------------------------------------------------------------------------------ # Speed up Vim escape key #------------------------------------------------------------------------------ # # Speed up the escape key delay in Vim to prevent Tmux and Neovim from # feeling sluggish or as if the terminal froze for a second. # set -sg escape-time 10 #------------------------------------------------------------------------------ # Navigate Tmux Sessions #------------------------------------------------------------------------------ # # Use ctrl+option up/down to switch to next or previous session # bind -n C-M-j switch-client -p bind -n C-M-k switch-client -n #------------------------------------------------------------------------------ # Navigate Tmux Windows #------------------------------------------------------------------------------ # # Use ctrl+option left/right to switch to next or previous window # Use ctrl+option n/p to swap current window with next or previous window # bind -n C-M-l next-window bind -n C-M-h previous-window bind -n C-M-p run-shell 'tmux swap-window -t -1 && tmux select-window -t :-' bind -n C-M-n run-shell 'tmux swap-window -t +1 && tmux select-window -t :+' #------------------------------------------------------------------------------ # Navigate Tmux Panes and Neovim Buffers #------------------------------------------------------------------------------ # # Use ctrl hjkl to navigate through both Tmux Panes and Neovim/Vim/HX Buffers. # is_program="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?(hx|vifm|g?(view|n?vim?x?)(diff)?)$'" bind -n 'C-h' if-shell "$is_program" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' } bind -n 'C-j' if-shell "$is_program" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' } bind -n 'C-k' if-shell "$is_program" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' } bind -n 'C-l' if-shell "$is_program" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' } #------------------------------------------------------------------------------ # Reload Configuration #------------------------------------------------------------------------------ # # Use u to reload the config. # bind u source-file ~/.config/tmux/tmux.conf \; display "Reloading..." #------------------------------------------------------------------------------ # Plugins #------------------------------------------------------------------------------ # # Use U to update the plugins. # set -g @plugin 'tmux-plugins/tpm' # add plugins here # run '~/.tmux/plugins/tpm/tpm' #