Last active
November 28, 2025 17:02
-
-
Save bloatfan/68180c4f47f85bdb36993680e8a0ca4b to your computer and use it in GitHub Desktop.
.tmux.conf
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
| # 支持鼠标模式 | |
| # set -g mouse on | |
| # 设置历史窗口缓冲大小 | |
| set -g history-limit 30000 | |
| # PREFIX-Q 显示编号的驻留时长,单位 ms | |
| set -g display-panes-time 10000 | |
| # 关掉某个窗口后,编号重排 | |
| set -g renumber-windows on | |
| # 进入复制模式的时候使用 vi 键位(默认是 EMACS) | |
| setw -g mode-keys vi | |
| # ----------------------------------------------------------------------------- | |
| # 使用插件 - via tpm | |
| # 1. 执行 git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |
| # ----------------------------------------------------------------------------- | |
| # 推荐的插件(请去每个插件的仓库下读一读使用教程) | |
| set -g @plugin 'seebi/tmux-colors-solarized' | |
| set -g @plugin 'tmux-plugins/tmux-pain-control' | |
| set -g @plugin 'tmux-plugins/tmux-prefix-highlight' | |
| set -g @plugin 'tmux-plugins/tpm' | |
| # 移动 pane 以及修改大小插件 | |
| # https://github.com/christoomey/vim-tmux-navigator#custom-key-bindings | |
| set -g @plugin 'christoomey/vim-tmux-navigator' | |
| set -g @plugin 'joshmedeski/tmux-nerd-font-window-name' | |
| set -g @plugin 'tmux-plugins/tmux-resurrect' | |
| # set -g @plugin 'niqodea/tmux-nested' | |
| # seebi/tmux-colors-solarized | |
| set -g @colors-solarized 'dark' | |
| # tmux-prefix-highlight | |
| set -g status-right '#{prefix_highlight} #H | %a %Y-%m-%d %H:%M' | |
| set -g @prefix_highlight_show_copy_mode 'on' | |
| set -g @prefix_highlight_copy_mode_attr 'fg=white,bg=blue' | |
| # https://github.com/roxma/vim-tmux-clipboard | |
| set -g focus-events on | |
| # 初始化 TPM 插件管理器 (放在配置文件的最后) | |
| run -b '~/.tmux/plugins/tpm/tpm' | |
| # 设置每次调整 pane 的大小,插件 tmux-pain-control | |
| # https://github.com/tmux-plugins/tmux-pain-control/blob/master/pain_control.tmux#L35 | |
| set -g @pane_resize 5 | |
| ################## BINDINGS ################## | |
| # 在 copy-mode-vi 模式下,使用 v 开始选择 | |
| bind -T copy-mode-vi v send-keys -X begin-selection | |
| # bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel | |
| bind -T copy-mode-vi y send-keys -X copy-selection | |
| # 在 normal 模式下鼠标滑轮进入 copy-mode, 左键释放后,即复制,我不喜欢这样的行为 | |
| # https://stackoverrun.com/cn/q/10149784 | |
| unbind -T copy-mode MouseDragEnd1Pane | |
| unbind -T copy-mode-vi MouseDragEnd1Pane | |
| # Alternatively, you can exclude the previous pane key binding from your ~/.tmux.conf | |
| # [How can I run a Tmux command based on the current operating system?](https://unix.stackexchange.com/questions/603750/how-can-i-run-a-tmux-command-based-on-the-current-operating-system) | |
| unbind -T copy-mode-vi C-\\ | |
| if-shell -b "true" { | |
| unbind -n C-\\ | |
| } | |
| # 使用 ctrl-j, ctrl-k, ctrl-h, ctrl-l 等映射,和 fzf 冲突 | |
| # 在这里设置好像不生效、要去 zsh 里面去设置 | |
| # unbind-key -Troot C-h | |
| # unbind-key -Troot C-j | |
| # unbind-key -Troot C-k | |
| # unbind-key -Troot C-l | |
| set -g default-terminal "screen-256color" | |
| set -ga terminal-overrides ",xterm-256color:Tc" | |
| # support yazi | |
| # https://github.com/sxyazi/yazi/wiki/Image-preview-within-tmux | |
| set -g allow-passthrough on | |
| set -ga update-environment TERM | |
| set -ga update-environment TERM_PROGRAM | |
| set -g set-clipboard on | |
| # [tmux.conf excerpt to toggle on/off session keybindings and prefix handling](https://gist.github.com/samoshkin/05e65f7f1c9b55d3fc7690b59d678734) | |
| # Activate OFF mode | |
| bind -n F1 set prefix None \; set key-table off \; set status-style "fg=colour245,bg=colour238" | |
| bind -n F2 set prefix None \; set key-table off \; set status-style "fg=colour245,bg=colour238" | |
| bind -n F3 set prefix None \; set key-table off \; set status-style "fg=colour245,bg=colour238" | |
| # Disable OFF mode | |
| bind -T off F1 set -u prefix \; set -u key-table \; set -u status-style | |
| bind -T off F2 set -u prefix \; set -u key-table \; set -u status-style | |
| bind -T off F3 set -u prefix \; set -u key-table \; set -u status-style |
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
| #!/bin/bash -x | |
| # 如果 download=1 则表示需要下载 tmux | |
| download=0 | |
| tmux=`which tmux` | |
| if [[ "$?" != "0" ]]; then | |
| download=1 | |
| fi | |
| version=`$tmux -V | awk ' { print $2 } '` | |
| if [[ "$version" < "2.1" ]]; then | |
| download=1 | |
| fi | |
| if [[ "$download" == "1" ]]; then | |
| wget "https://github.com/lslz627/software/raw/master/tmux/bin/tmux" -O /usr/local/bin/tmux | |
| chmod u+x /usr/local/bin/tmux | |
| tmux="/usr/local/bin/tmux" | |
| fi | |
| [[ -d "${HOME}/.tmux/plugins" ]] || mkdir -p "${HOME}/.tmux/plugins" | |
| [[ -d "${HOME}/.tmux/plugins/tpm" ]] || git clone https://github.com/tmux-plugins/tpm ${HOME}/.tmux/plugins/tpm | |
| wget https://gist.githubusercontent.com/lslz627/68180c4f47f85bdb36993680e8a0ca4b/raw/.tmux.conf -O ~/.tmux.conf | |
| $tmux new -s tmux_init -d | |
| $tmux send -t "tmux_init:0" "$tmux run-shell $HOME/.tmux/plugins/tpm/bindings/install_plugins" Enter | |
| # tmux run-shell $HOME/.tmux/plugins/tpm/bindings/install_plugins | |
| $tmux send -t "tmux_init:0" "exit" Enter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment