Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save idcmardelplata/dabfac442af8d6d09e7ec081f48f12fe to your computer and use it in GitHub Desktop.
Save idcmardelplata/dabfac442af8d6d09e7ec081f48f12fe to your computer and use it in GitHub Desktop.
Configuracion de tmux
# Load plugins.
# We don't actually need to set the one-dark theme, I've customised the vanilla
# tmux configuration to my liking. If this seems to be working well then I will
# later remove this line.
# set -g @plugin 'odedlaz/tmux-onedark-theme' # OneDark Theme
# Remap prefix to ctrl-a for screen consistency.
set -g prefix C-a
# Restore using continuum.
set -g @continuum-restore 'off'
# Configuration management.
# Reload configuration file.
bind R source-file ~/.tmux.conf |; display "Sourced ~/.tmux.conf"
# Shell management.
# Set the default shell, and set the default command to use our shell (this
# means we source things properly, show the correct PS1 etc).
set -g default-shell ${SHELL}
set -g default-command ${SHELL}
# Mouse management.
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# Colour management (yikes) and alert management.
# Use 256 colours.
set-option -ga terminal-overrides ",xterm-256color:Tc"
set-option -g default-terminal "screen-256color"
# Enable visual alerts for windows. Hide bells/silence.
set-window-option -g monitor-activity off # highlight active windows?
set-option -g visual-activity off # show a message on window activity?
set-option -g visual-silence off
set-option -g visual-bell off
set-option -g bell-action none
# Nested session configuration.
# Use ^b b to send the leader to a nested session. This means if you are
# using tmux and then ssh into a tmux session (i.e. a nested session) you
# can run commands in the nested session with ^B b <command>.
bind-key b send-prefix
# Keyboard Management.
# Don't wait for an escape sequence after hitting
# Esc. fixes insert mode exit lag in vim.
set -sg escape-time 0
# Clipboard / Copy / Paste
# Note: This is heavily OS dependent, which is why we have separate versions
# for OSX, Ubuntu etc. I'm trying out tmux-yank for this but it is still work in
# progress.
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' begin/end selection as in Vim.
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Pane and Window Management.
# Open new panes and splits in the same working directory.
bind c new-window -c "#{pane_current_path}"
# Set the name of the window initially, but then don't let tmux change it.
# The name can still be set at any time with Ctrl+B + ,
set-option -g allow-rename off
# Start windows and panes at 1.
set -g base-index 1
set -g pane-base-index 1
# When we add/remove windows, renumber them in sequential order.
set -g renumber-windows on
# Split panes using | and -
bind _ split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Ctrl+B h/l to swap windows left/right, i.e. moving the tabs around.
bind-key h swap-window -t -1\; select-window -t -1
bind-key l swap-window -t +1\; select-window -t +1
# Smart pane switching with awareness of Vim splits, as well as Ctrl+HJKL in
# the fzf command.
# See: https://github.com/christoomey/vim-tmux-navigator
# See: https://www.bugsnag.com/blog/tmux-and-vim
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
bind -n C-h run "($is_vim && tmux send-keys C-h) || \
tmux select-pane -L"
bind -n C-j run "($is_vim && tmux send-keys C-j) || \
($is_fzf && tmux send-keys C-j) || \
tmux select-pane -D"
bind -n C-k run "($is_vim && tmux send-keys C-k) || \
($is_fzf && tmux send-keys C-k) || \
tmux select-pane -U"
bind -n C-l run "($is_vim && tmux send-keys C-l) || \
tmux 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'"
# Move through panes with hjkl
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
# Meta + h/l to cycle through tabs.
bind-key -n M-h previous-window
bind-key -n M-l next-window
# Ctr + Meta + h/j/k/l to resize panes.
bind-key -n C-M-h resize-pane -L 2
bind-key -n C-M-j resize-pane -D 2
bind-key -n C-M-k resize-pane -U 2
bind-key -n C-M-l resize-pane -R 2
# Enable focus events, which are needed to keep vim's focus events working when
# vim is running inside tmux.
set -g focus-events on
## Status bar design
# set -g status-utf8 on
set -g status-justify left
set -g status-position top
set -g status-bg default
set -g status-interval 2
# Customise the visuals on top of One Dark for tmux. Might be good to put into
# its own file at some stage.
onedark_black="#282C34"
dark_black="#1c1c1c"
white="#ffffff"
set -g pane-border-style "fg=color238 bg=#282C34" # i.e. "$onedark_black"
set -g pane-active-border-style "fg=color14 bg=#282C34" # i.e. "$onedark_black"
# Info on left (I don't have a session display for now)
# set -g status-left ''
set -g status-style "bg=black"
set -g status-left '#[fg=color16,bold]#S '
set -g status-right ' #[fg=color250] %Y-%m-%d #[fg=white,bold]%H:%M:%S'
set -g status-right-length 50
set -g status-left-length 20
# Set the style for windows.
# TODO: note that the 'red' in the status is not being shown, this is because we
# need a multi-conditional at the moment these are sequential so the most recent
# overwrite the others.
# setw -g window-status-format '#I#[fg=colour245]:#[fg=color250]#{?window_activity_flag, #[fg=green],}#{?window_bell_flag,#[fg=red]#[blink],}#W#[fg=colour50]#F '
# This is the same status as above, with no highlight for activity.
setw -g window-status-format '#I#[fg=colour245,bg=black]:#W#[fg=colour50,bg=black]#F '
# Set the style for the _current_ window.
setw -g window-status-current-format '#[fg=color250,bg=black]#I#[fg=color245]:#[fg=color255,bold]#W#[fg=colour50]#F '
# set -g @plugin 'tmux-plugins/tmux-yank' # Cross-platform support for clipboard.
set -g @plugin 'omerxx/tmux-sessionx'
set -g @sessionx-x-path '$HOME/'
set -g @sessionx-window-mode 'on'
set -g @sessionx-preview-location 'right'
set -g @sessionx-preview-ratio '55%'
set -g @sessionx-preview-enabled 'true'
set -g @sessionx-zoxide-mode 'on'
set -g @plugin 'tmux-plugins/tmux-resurrect' # Save/Restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum' # Auto Save/Restore
set -g @plugin 'catppuccin/tmux'
set -g @catppuccin_flavour 'frappe'
set -g @catppuccin_window_default_text "#W" # use "#W" for application instead of directory
set -g @catppuccin_status_modules_right "application session date_time"
set -g @plugin 'tmux-plugins/tpm'
# set -g @plugin 'omerxx/tmux-sessionx'
# Configure sessionx
# set -g @sessionx-bind 'o'
# set -g @sessionx-x-path '~/.config/'
# set -g @sessionx-window-mode 'off'
# set -g @sessionx-preview-location 'right'
# set -g @sessionx-preview-ratio '55%'
# set -g @sessionx-layout 'reverse'
# set -g @sessionx-prompt " "
# set -g @sessionx-pointer "▶ "
#Yazi Config
set -g allow-passthrough on
set -ga update-environment TERM
set -ga update-environment TERM_PROGRAM
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment