Skip to content

Instantly share code, notes, and snippets.

@AlanJui
Last active February 22, 2024 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlanJui/84aae51194ca2b3edfe17a72ea376caa to your computer and use it in GitHub Desktop.
Save AlanJui/84aae51194ca2b3edfe17a72ea376caa to your computer and use it in GitHub Desktop.

Tmux 2004 簡捷配置指引

~/.tmux.conf

source-file ~/.tmux.reset.conf
set-option -g default-terminal 'screen-254color'
set-option -g terminal-overrides ',xterm-256color:RGB'

set-option -g prefix ^A
set-option -g base-index 1              # start indexing windows at 1 instead of 0
set-option -g detach-on-destroy off     # don't exit from tmux when closing a session
set-option -g escape-time 0             # zero-out escape time delay
set-option -g history-limit 1000000     # increase history size (from 2,000)
set-option -g renumber-windows on       # renumber all windows when any window is closed
set-option -g set-clipboard on          # use system clipboard
set-option -g status-position top       # macOS / darwin style
set-option -g default-terminal "${TERM}"
set-option -g pane-active-border-style 'fg=magenta,bg=default'
set-option -g pane-border-style 'fg=brightblack,bg=default'

# Scroll shell output with mouse
set-window-option -g mouse on

# force Vi mode
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection

set -g @fzf-url-fzf-options '-p 60%,30% --prompt="   " --border-label=" Open URL "'
set -g @fzf-url-history-limit '2000'

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'fcsonline/tmux-thumbs'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'wfxr/tmux-fzf-url'
set -g @plugin 'omerxx/catppuccin-tmux' # My fork that holds the meetings script bc I'm lazy af
set -g @plugin 'omerxx/tmux-sessionx'

set -g @sessionx-bind 'o'
# set -g @sessionx-x-path '~/dotfiles'
set -g @sessionx-window-height '85%'
set -g @sessionx-window-width '75%'
set -g @sessionx-zoxide-mode 'on'

set -g @continuum-save-interval '10'
set -g @continuum-restore 'on'
set -g @resurrect-strategy-nvim 'session'

set -g @catppuccin_window_left_separator ""
set -g @catppuccin_window_right_separator ""
set -g @catppuccin_window_middle_separator ""
set -g @catppuccin_window_number_position "right"
set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_current_fill "number"
set -g @catppuccin_window_current_text "#W#{?window_zoomed_flag,(),}"
set -g @catppuccin_status_modules_right "directory meetings date_time"
set -g @catppuccin_status_modules_left "session"
set -g @catppuccin_status_left_separator  ""
set -g @catppuccin_status_right_separator ""
set -g @catppuccin_status_right_separator_inverse "no"
set -g @catppuccin_status_fill "icon"
set -g @catppuccin_status_connect_separator "no"
set -g @catppuccin_directory_text "#{b:pane_current_path}"
set -g @catppuccin_meetings_text "#($HOME/.config/tmux/scripts/cal.sh)"
set -g @catppuccin_date_time_text "%H:%M"

run '~/.tmux/plugins/tpm/tpm'

~/.tmux.reset.conf

# First remove *all* keybind-keyings
# unbind-key-key -a
# Now reinsert all the regular tmux keys
bind-key ^X lock-server
bind-key ^C new-window -c "$HOME"
bind-key ^D detach
bind-key * list-clients

bind-key H previous-window
bind-key L next-window

bind-key r command-prompt "rename-window %%"
bind-key R source-file ~/.tmux.conf
bind-key ^A last-window
bind-key ^W list-windows
bind-key w list-windows
bind-key z resize-pane -Z
bind-key ^L refresh-client
bind-key l refresh-client
bind-key - split-window -fv
bind-key _ split-window -h
bind-key | split-window -h
bind-key s split-window -v -c "#{pane_current_path}"
bind-key v split-window -h -c "#{pane_current_path}"
bind-key '"' choose-window
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key -r -T prefix [ resize-pane -L 20
bind-key -r -T prefix ] resize-pane -R 20
bind-key -r -T prefix , resize-pane -D 7
bind-key -r -T prefix . resize-pane -U 7
bind-key : command-prompt
bind-key * setw synchronize-panes
bind-key P set pane-border-status
bind-key c swap-pane -D
bind-key X kill-pane
bind-key S choose-session

# Shift arrow to switch windows
bind-key -n M-Left  previous-window
bind-key -n M-Right next-window

# Switch window
bind-key -n C-S-Left { swap-window -t -1; previous-window } # Ctrl+Shift+Left  window向左(不需要prefix)
bind-key -n C-S-Right { swap-window -t +1; next-window }    #  Ctrl+Shift+Left window向右(不需要prefix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment