Last active
October 4, 2024 09:20
-
-
Save pengshp/571c28cac6f41fe7d532823c41a6f5d6 to your computer and use it in GitHub Desktop.
~/.config/tmux/tmux.conf tmux3.3a+ config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# _ __ | |
# | |_ _ __ ___ _ ___ __ ___ ___ _ __ / _| | |
# | __| '_ ` _ \| | | \ \/ / / __/ _ \| '_ \| |_ | |
# | |_| | | | | | |_| |> < | (_| (_) | | | | _| | |
#(_)__|_| |_| |_|\__,_/_/\_(_)___\___/|_| |_|_| | |
# tmux version tmux 3.5 | |
# https://github.com/tmux/tmux | |
## 配置参考:http://louiszhai.github.io/2017/09/30/tmux/ | |
# 从tmux v1.6版起,支持设置第二个指令前缀 | |
# 设置一个不常用的键Ctrl+a作为指令前缀,按键更快些 | |
set-option -g prefix2 C-a | |
## 面板管理 | |
unbind '"' | |
bind - splitw -v -c '#{pane_current_path}' | |
# 垂直方向新增面板,默认进入当前目录 | |
unbind % | |
bind | splitw -h -c '#{pane_current_path}' | |
# 水平方向新增面板,默认进入当前目录 | |
# Set easier window split keys | |
bind-key v split-window -h | |
bind-key h split-window -v | |
# Use <Alt-arrow> keys to switch panes | |
bind -n M-Left select-pane -L | |
bind -n M-Right select-pane -R | |
bind -n M-Up select-pane -U | |
bind -n M-Down select-pane -D | |
# <Shift arrow> to switch windows | |
bind -n S-Left previous-window | |
bind -n S-Right next-window | |
# Easy config reload | |
bind-key x kill-pane # skip "kill-pane 1? (y/n)" prompt | |
# Pane border styles | |
set -g pane-active-border-style "bg=default,fg=cyan" | |
set -g pane-border-style "bg=default,fg=cyan" | |
# 开启鼠标的支持 | |
set-option -g mouse on | |
set-option -g set-clipboard on # use system clipboard | |
set-option -g detach-on-destroy off | |
## 面板大小调整 | |
# 绑定Ctrl+hjkl键为面板上下左右调整边缘的快捷指令 | |
bind -r ^k resizep -U 10 # 绑定Ctrl+k为往↑调整面板边缘10个单元格 | |
bind -r ^j resizep -D 10 # 绑定Ctrl+j为往↓调整面板边缘10个单元格 | |
bind -r ^h resizep -L 10 # 绑定Ctrl+h为往←调整面板边缘10个单元格 | |
bind -r ^l resizep -R 10 # 绑定Ctrl+l为往→调整面板边缘10个单元格 | |
## 其它配置 | |
bind m command-prompt "splitw -h 'exec man %%'" | |
# 绑定m键为在新的panel打开man | |
# 绑定P键为开启日志功能,如下,面板的输出日志将存储到/tmp | |
bind P pipe-pane -o "cat >>/tmp/#W.log" \; display "Toggled logging to /tmp/#W.log" | |
# tmux + fzf + sesh | |
# https://github.com/joshmedeski/sesh | |
# prefix + T | |
bind-key "T" run-shell "sesh connect \"$( | |
sesh list | fzf-tmux -p 60%,60% \ | |
--no-sort --ansi --border-label ' sesh ' --prompt ' ' \ | |
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \ | |
--bind 'tab:down,btab:up' \ | |
--bind 'ctrl-a:change-prompt( )+reload(sesh list)' \ | |
--bind 'ctrl-t:change-prompt( )+reload(sesh list -t)' \ | |
--bind 'ctrl-g:change-prompt( )+reload(sesh list -c)' \ | |
--bind 'ctrl-x:change-prompt( )+reload(sesh list -z)' \ | |
--bind 'ctrl-f:change-prompt( )+reload(fd -H -d 2 -t d -E .Trash . ~)' \ | |
--bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚡ )+reload(sesh list)' | |
)\"" | |
# gum + tmux | |
# prefix + K | |
bind-key "K" display-popup -E -w 40% "sesh connect \"$( | |
sesh list -i | gum filter --limit 1 --placeholder 'Pick a sesh' --height 50 --prompt='⚡' | |
)\"" | |
# prefix + L | |
bind -N "last-session (via sesh) " L run-shell "sesh last" | |
bind -N "switch to root session (via sesh) " 9 run-shell "sesh connect --root \'$(pwd)\'" | |
## 复制操作 | |
# 开启vi风格后,支持vi的C-d、C-u、hjkl等快捷键 | |
setw -g mode-keys vi | |
# tmux v2.4+ v 选择 y 复制 | |
bind-key -T copy-mode-vi v send-keys -X begin-selection | |
bind-key -T copy-mode-vi V send -X select-line | |
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel | |
# Window and pane indices | |
set -g base-index 1 # 设置窗口的起始下标为1 | |
set -g pane-base-index 1 # 设置面板的起始下标为1 | |
set-window-option -g pane-base-index 1 | |
set-option -g renumber-windows on | |
# tmux-continuum | |
# set -g @resurrect-capture-pane-contents 'on' | |
set -g @continuum-restore 'on' | |
# -------------- start ---------------------- | |
# tokyo-night-tmux config | |
set -g @tokyo-night-tmux_window_id_style fsquare | |
set -g @tokyo-night-tmux_pane_id_style hsquare | |
set -g @tokyo-night-tmux_zoom_id_style dsquare | |
set -g @tokyo-night-tmux_show_path 1 | |
set -g @tokyo-night-tmux_path_format relative | |
set -g @tokyo-night-tmux_show_netspeed 1 | |
set -g @tokyo-night-tmux_netspeed_iface "eno1" | |
set -g @tokyo-night-tmux_netspeed_showip 0 | |
set -g @tokyo-night-tmux_netspeed_refresh 5 | |
set -g @tokyo-night-tmux_show_datetime 0 | |
set -g @tokyo-night-tmux_date_format MYD | |
set -g @tokyo-night-tmux_time_format 12H | |
# ---------------- end ---------------------- | |
# tmux-fzf | |
# prefix + F | |
TMUX_FZF_MENU=\ | |
"bottom\nbtm\n"\ | |
"gitui\ngitui\n"\ | |
"htop\nhtop\n" | |
##--------- tpm ----------------------------------- | |
# List of plugins | |
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
set -g @plugin "janoamaral/tokyo-night-tmux" | |
# persist tmux sessions after computer restart | |
set -g @plugin 'tmux-plugins/tmux-resurrect' | |
# automatically saves sessions for you every 15 minutes | |
set -g @plugin 'tmux-plugins/tmux-continuum' | |
set -g @plugin 'sainnhe/tmux-fzf' | |
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
run '~/.config/tmux/plugins/tpm/tpm' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment