Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Set the TMUX_CONF variable to track the location of the current tmux configuration file.
- # Set the TMUX_PROGRAM variable to track the path of the tmux binary being used.
- %if #{==:#{TMUX_PROGRAM},}
- run 'TMUX_PROGRAM="$(LSOF=$(PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command -v lsof); \
- $LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g && \
- s/(?:\s+\([^\s]+?\))?$//g) { print; exit } } exit 1; {" || readlink "/proc/#{pid}/exe" 2>/dev/null)"; \
- {[ -f "$TMUX_PROGRAM" ] && [ -x "$TMUX_PROGRAM" ]} || TMUX_PROGRAM="$(command -v tmux || printf tmux)"; \
- "$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_PROGRAM "$TMUX_PROGRAM"'
- %endif
- # Set the TMUX_SOCKET variable to track the socket path being used by tmux.
- %if #{==:#{TMUX_SOCKET},}
- run '"$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_SOCKET "#{socket_path}"'
- %endif
- # Set the TMUX_CONF variable to track the location of the tmux configuration file.
- %if #{==:#{TMUX_CONF},}
- run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF $(for conf in "$HOME/.tmux.conf" "$XDG_CONFIG_HOME/tmux/tmux.conf" \
- "$HOME/.config/tmux/tmux.conf"; do [ -f "$conf" ] && printf "%s" "$conf" && break; done)'
- %endif
- # Keybinding to open and source the tmux configuration file in a new window using the preferred editor.
- bind e new-window -n "tmux.conf" -e EDITOR="$EDITOR" sh -c '
- # Check if nvim is available; use it if present, otherwise fall back to the current editor.
- if command -v nvim >/dev/null 2>&1; then
- EDITOR=nvim
- fi
- # Open the tmux config file with the determined editor, setting appropriate syntax highlighting.
- case "${EDITOR:-vim}" in
- *vim*) ${EDITOR:-vim} -c ":set syntax=tmux" "$TMUX_CONF";;
- *) $EDITOR ~/.config/tmux/tmux.conf;;
- esac && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF sourced"
- '
- # Keybinding to open ~/.zshrc file in a new tmux window using the preferred editor.
- bind | new-window -n "zshrc" -e EDITOR="$EDITOR" sh -c '
- # Check if nvim is available; use it if present, otherwise fall back to the current editor.
- if command -v nvim >/dev/null 2>&1; then
- EDITOR=nvim
- else
- EDITOR=${EDITOR:-vim}
- fi
- # Open the .zshrc file with the determined editor, setting appropriate syntax highlighting.
- case "$EDITOR" in
- *vim*) $EDITOR -c ":set syntax=zsh" "$HOME/.zshrc";;
- *) $EDITOR "$HOME/.zshrc";;
- esac && source "$HOME/.zshrc"; display "~/.zshrc sourced"
- '
- # Keybinding to reload the tmux configuration file.
- bind r run '"$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF"' \; display "#{TMUX_CONF} sourced"
- # -- general -------------------------------------------------------------------
- # Enable true color support in xterm-compatible terminals.
- set-option -sa terminal-overrides ",xterm*:Tc"
- # Enable focus events to detect when the terminal gains or loses focus.
- set -s focus-events on
- # Enable mouse support for selecting panes, resizing, and scrolling.
- set -g mouse on
- # Unset the default prefix key
- unbind C-b
- # Set an additional prefix key for tmux commands.
- set -g prefix C-a
- # Allow the use of the secondary prefix key (C-a) to send the original prefix key.
- bind -n C-a send-prefix
- # -- display -------------------------------------------------------------------
- # Start window numbering from 1.
- set -g base-index 1
- # Ensure pane numbering is consistent with window numbering.
- setw -g pane-base-index 1
- # Automatically rename windows to reflect the currently active program.
- set -g automatic-rename on
- # Renumber windows after closing a window.
- set -g renumber-windows on
- # Set the terminal title to reflect the current tmux session and window.
- set -g set-titles on
- # Set the terminal title string to show pane title, session name, and window details.
- set -g set-titles-string '#{pane_title} ❐ #{session_name} ❐ #{window_index}:#{window_name}'
- # Set a slightly longer display time for pane indicators.
- set -g display-panes-time 800
- # Set a slightly longer display time for status messages.
- set -g display-time 1000
- # Ensure pane numbering starts from 1 in each window.
- set-window-option -g pane-base-index 1
- # Enable pane border status at the top
- set -w pane-border-status top # removed the -g flag cause it was being over written by theme
- # Zen-full pane border format with minimal and useful information
- set -g pane-border-format "#{pane_current_command}"
- # set-hook -g after-new-window 'set allow-passthrough on'
- # set -g visual-activity off
- # -- navigation ----------------------------------------------------------------
- # Bind C-c to create a new tmux session.
- bind C-c new-session
- # Bind C-f to prompt for finding a session and switching to it.
- bind C-f command-prompt -p find-session 'switch-client -t %%'
- # Bind BTab to switch to the last active session.
- bind BTab switch-client -l
- # Split the current window horizontally with a new pane.
- bind - split-window -v
- # Split the current window vertically with a new pane.
- bind _ split-window -h
- # Split the current window horizontally, maintaining the current pane's working directory.
- bind - split-window -v -c "#{pane_current_path}"
- # Split the current window vertically, maintaining the current pane's working directory.
- bind _ split-window -h -c "#{pane_current_path}"
- # Commenting below pane movement keys since we are already using
- # christoomey/vim-tmux-navigator plugin which provides C-hjkl movements
- # but without <prefix>before them
- # Bind h, j, k, l for easy pane navigation in all directions.
- #bind -r h select-pane -L # move left
- #bind -r j select-pane -D # move down
- #bind -r k select-pane -U # move up
- #bind -r l select-pane -R # move right
- # Bind > and < for swapping panes with the next or previous pane.
- bind > swap-pane -D
- bind < swap-pane -U
- # Bind H, J, K, L for resizing panes in all directions.
- bind -r H resize-pane -L 2
- bind -r J resize-pane -D 2
- bind -r K resize-pane -U 2
- bind -r L resize-pane -R 2
- # Unbind default navigation keys for previous and next window.
- unbind n
- unbind p
- # Bind C-h and C-l for window navigation: previous and next window respectively.
- bind -r C-h previous-window
- bind -r C-l next-window
- # Bind Tab to switch to the last active window.
- bind Tab last-window
- # -- copy mode -----------------------------------------------------------------
- # Bind Enter to enter copy mode in tmux.
- bind Enter copy-mode -e
- # Use vi-style key bindings in copy mode.
- setw -g mode-keys vi
- # Bind v for starting selection, C-v for rectangle selection, and y for yanking in vi-mode.
- bind -T copy-mode-vi v send -X begin-selection
- bind -T copy-mode-vi C-v send -X rectangle-toggle
- bind -T copy-mode-vi y send -X copy-selection-and-cancel
- # Bind Escape to cancel copy mode in vi-style.
- bind -T copy-mode-vi Escape send -X cancel
- # Bind H and L to move to the start and end of the line in vi-style copy mode.
- bind -T copy-mode-vi H send -X start-of-line
- bind -T copy-mode-vi L send -X end-of-line
- # Copy mouse selected selection to system clipboard
- bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection
- # bind C to open a new pane to enter copy mode for the current panr
- bind C {
- splitw -f -l30% ''
- set-hook -p pane-mode-changed 'if -F "#{!=:#{pane_mode},copy-mode}" "kill-pane"'
- copy-mode -s'{last}'
- }
- # -- buffers -------------------------------------------------------------------
- # Bind b to list available paste buffers.
- bind b list-buffers
- # Bind p to paste the top buffer content.
- bind p paste-buffer -p
- # Bind P to choose which buffer to paste from.
- bind P choose-buffer
- # -- plugin settings -----------------------------------------------------------
- # Set options for the Catppuccin tmux theme.
- set -g @catppuccin_flavour 'mocha'
- # Set options for the Tokyo Night tmux theme.
- set -g @tokyo-night-tmux_show_datetime 0
- set -g @tokyo-night-tmux_show_path 1
- set -g @tokyo-night-tmux_path_format relative
- set -g @tokyo-night-tmux_window_id_style dsquare
- set -g @tokyo-night-tmux_pane_id_style hsquare
- set -g @tokyo-night-tmux_show_git 1
- # resurrect settings
- set -g @resurrect-capture-pane-contents 'on'
- set -g @resurrect-strategy-nvim 'session'
- # List of plugins to load with tmux.
- set -g @plugin 'tmux-plugins/tpm'
- set -g @plugin 'tmux-plugins/tmux-sensible'
- set -g @plugin 'christoomey/vim-tmux-navigator'
- set -g @plugin 'dreamsofcode-io/tokyo-night-tmux'
- # set -g @plugin 'catppuccin/tmux'
- set -g @plugin 'tmux-plugins/tmux-resurrect'
- set -g @plugin 'tmux-plugins/tmux-continuum'
- # Initialize TPM (Tmux Plugin Manager) for managing plugins.
- run -b '~/.tmux/plugins/tpm/tpm'
- # Temporary settings
- set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' # see :h tui-cursor-shape in nvim for this setting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement