apt install libevent-dev autotools-dev automake bison
git clone https://github.com/tmux/tmux.git
sh autogen.sh && \
./configure && \
make
make install
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
pip install tmuxp
Mucho, mucho de esta configuración está basado en esta serie de posts de Alexey Samoshkin
Emacs key bindings (prefix + :)
set -g status-keys emacs
Aumentar el history
set -g history-limit 50000
Deshabilitar el mouse
set -g mouse off
set -g default-terminal "screen-256color"
setw -g xterm-keys on
set -s escape-time 10 # Secuencias de comandos más rápidas
set -sg repeat-time 600 # Incrementar el timeout en las repeticiones
set -g focus-events on
setw -q -g utf8 on
set -s escape 1 # Cambiando el delay al mandar comandos
bind-key S run-shell "tmux rename-session $(basename $(pwd))"
Prompt to rename window right after it’s created
#set-hook -g after-new-window 'command-prompt -I "#{window_name}" "rename-window '%%'"'
bind-key -T copy-mode M-w send-keys -X copy-pipe-and-cancel "xclip -selection clipboard -i"
Recarga el archivo de configuración de tmux
bind r source-file ~/.tmux.conf \; display "¡tmux.conf Recargado!"
Limpia la pantalla y la historia
bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history
Nueva ventana y retiene el current working directory
bind c new-window -c "#{pane_current_path}"
bind C-b send-prefix # Para usarlo con aplicaciones (hay que presionar dos veces)
bind b list-buffers # Lista paste buffers
bind p paste-buffer # paste from el top paste buffer
bind P choose-buffer # escoge a cual buffer pegar
# Kill pane/window/session shortcuts
bind x kill-pane
bind X kill-window
bind C-x confirm-before -p "kill other windows? (y/n)" "kill-window -a"
bind Q confirm-before -p "kill-session #S? (y/n)" kill-session
# Merge session with another one (e.g. move all windows)
# If you use adhoc 1-window sessions, and you want to preserve session upon exit
# but don't want to create a lot of small unnamed 1-window sessions around
# move all windows from current session to main named one (dev, work, etc)
bind C-u command-prompt -p "Session to merge with: " \
"run-shell 'yes | head -n #{session_windows} | xargs -I {} -n 1 tmux movew -t %%'"
# Detach from session
bind d detach
#bind D if -F '#{session_many_attached}' \
# 'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \
# 'display "Session has only 1 client attached"'
# División de la ventana
bind | split-window -h -c "#{pane_current_path}" # Divide la pantalla horizontalmente
bind - split-window -v -c "#{pane_current_path}" # Divide la pantalla verticalmente
# Cambiando el tamaño de los páneles
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# create session
bind C-c new-session
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%'
bind m setw monitor-activity \; display-message 'Monitor window activity [#{?monitor-activity,ON,OFF}]'
Plugins: TPM
Key bindings
prefix + | Action |
---|---|
i | Instala nuevos plugins desde algún repositorio de git |
u | Actualiza los plugins |
Alt + u | Desinstala los plugins que ya no están listados |
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
set -g @plugin "tmux-plugins/tpm"
set -g @plugin "tmux-plugins/tmux-copycat"
# Feel free to NOT use this variables at all (remove, rename)
# this are named colors, just for convenience
color_orange="colour166" # 208, 166
color_purple="colour134" # 135, 134
color_green="colour076" # 070
color_blue="colour39"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white" # 015
# This is a theme CONTRACT, you are required to define variables below
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"
set -g @plugin 'seebi/tmux-colors-solarized'
#set -g @colors-solarized '256'
#set -g @colors-solarized 'dark'
set -g @colors-solarized 'light'
#set -g @colors-solarized 'base16'
setw -g aggressive-resize on
Títulos de ventana
set -g set-titles-string "tmux:#I #W"
setw -g window-status-format "#[bg=NONE]#[fg=colour240] #I #[bg=NONE]#[fg=colour240] #W "
setw -g window-status-current-format "#[fg=colour246]#[bg=NONE] #I #[bg=NONE]#[fg=colour246] #W#F "
#setw -g window-status-style "fg=$color_status_text,bg=$color_dark"
#setw -g window-status-format "tmux: #I #W "
#setw -g window-status-current-style "fg=$color_light,bold,bg=$color_main"
#setw -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]"
set -g base-index 1 # El índice de las ventanas empieza en 1
set -g pane-base-index 1 # El índice de los páneles empieza en 1
setw -g automatic-rename on # rename window to reflect current program
set -g renumber-windows on # renumber windows when a window is closed
set -g set-titles on # set terminal title
set -g display-panes-time 800 # slightly longer pane indicators display time
set -g display-time 1500 # slightly longer status messages display time (1.5s)
set -g status-interval 5 # redraw status line every 10 seconds
set -g monitor-activity on # Monitorizar la actividad en las ventanas
set -g visual-activity on
Colores de mensajes
# Colorize the messages in the command
set-option -g message-bg colour235
set-option -g message-fg red
# Sane colors for a light background
set -g status-bg colour8
set -g status-fg colour1
set-window-option -g window-status-current-fg colour15
Colores varios
# hostname color
set -g status-left ' #[fg=colour2]★'
# right status and color
set -g status-right-length 40
set -g status-right '#[fg=colour3]%a %h-%d %H:%M'
set -g update-environment \
"DISPLAY\
SSH_ASKPASS\
SSH_AUTH_SOCK\
SSH_AGENT_PID\
SSH_CONNECTION\
SSH_TTY\
WINDOWID\
XAUTHORITY"
bind '$' run "~/dotfiles/renew_env.sh"
Movimiento entre páneles
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
Swaping panes
bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one
Movimiento circular entre ventanas
unbind n
unbind p
bind -r C-p previous-window # select previous window
bind -r C-n next-window # select next window
bind Tab last-window # move to last active window
Para que esto funcione, tmux
debe de estar instalado en el servidor
SSH
y ambos archivos de configuración deben de estar en él.
# Session is considered to be remote when we ssh into host
if-shell 'test -n "$SSH_CLIENT"' \
'source-file ~/.tmux.remote.conf'
# We want to have single prefix key "C-a", usable both for local and remote session
# we don't want to "C-a" + "a" approach either
# Idea is to turn off all key bindings and prefix handling on local session,
# so that all keystrokes are passed to inner/remote session
# see: toggle on/off all keybindings · Issue #237 · tmux/tmux - https://github.com/tmux/tmux/issues/237
# Also, change some visual styles when window keys are off
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
set -u prefix \;\
set -u key-table \;\
set -u status-style \;\
set -u window-status-current-style \;\
set -u window-status-current-format \;\
refresh-client -S
run -b '~/.tmux/plugins/tpm/tpm'
# show status bar at top for remote session,
# so it do not stack together with local session's one
set -g status-position top
# Set port of SSH remote tunnel, where tmux will pipe buffers to transfer on local machine for copy
set -g @copy_backend_remote_tunnel_port 11988
# In remote mode we don't show "clock" and "battery status" widgets
#set -g status-left "$wg_session"
#set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}"