Created
July 22, 2020 06:12
-
-
Save jouyouyun/7968c531e4a3647d5c4de3c1ce831f7a to your computer and use it in GitHub Desktop.
tmux configuration
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
#此类配置可以在命令行模式中输入show-options -g查询 | |
#窗口的初始序号;默认为0,这里设置为1 | |
set-option -g base-index 1 | |
#提示信息的持续时间;设置足够的时间以避免看不清提示,单位为毫秒 | |
set-option -g display-time 5000 | |
#控制台激活后的持续时间;设置合适的时间以避免每次操作都要先激活控制台,单位为毫秒 | |
set-option -g repeat-time 1000 | |
#操作状态栏时的默认键盘布局;可以设置为vi或emacs | |
#set-option -g status-keys vi | |
set-option -g status-keys emacs | |
#开启窗口的UTF-8支持 | |
#set-window-option -g utf8 on | |
# When a smaller terminal connects to a tmux client, it shrinks to fit it. | |
# The clients attached with bigger displays see this constrained view. | |
# aggressive-resize makes it such that the window is only resized | |
# if the smaller client is actively looking at it. | |
setw -g aggressive-resize on | |
# Active switching the currently focused pane by mouse click | |
#set -g mouse on | |
# Set the title of the current window to something desc | |
set-option -g set-titles on | |
# window number,program name, active(or not) | |
set-option -g set-titles-string '#H:#S.#I.#P #W #T' | |
#此类设置可以在命令行模式中输入show-window-options -g查询 | |
#复制模式中的默认键盘布局;可以设置为vi或emacs | |
#set-window-option -g mode-keys vi | |
#bind-key -t vi-copy 'v' begin-selection | |
#bind-key -t vi-copy 'y' copy-selection | |
set-window-option -g mode-keys vi | |
# move tmux copy buffer into x clipboard | |
#bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard' | |
#bind y run "tmux save-buffer - | xclip -selection c"\; display-message "Buffer copied to clipboard" | |
# Emacs style | |
#bind-key -t emacs-copy y copy-pipe "xsel -i -p && xsel -o -p | xsel -i -b" | |
#bind-key C-y run "xsel -o | tmux load-buffer - ; tmux paste-buffer" | |
# Vim style | |
#bind-key -t vi-copy y copy-pipe "xsel -i -p && xsel -o -p | xsel -i -b" | |
#bind-key p run "xsel -o | tmux load-buffer - ; tmux paste-buffer" | |
# xclip | |
#bind-key -t vi-copy y copy-pipe "xclip -i -sel clip > /dev/null" | |
#bind-key p run "xclip -o -sel clip | tmux load-buffer - ; tmux paste-buffer" | |
###将激活控制台的快捷键由Ctrl+b修改为Ctrl+z | |
set-option -g prefix C-z | |
unbind-key C-b | |
bind-key C-z send-prefix | |
# buffer:up, down, left, right | |
bind-key k select-pane -U | |
bind-key j select-pane -D | |
bind-key h select-pane -L | |
bind-key l select-pane -R | |
#unbind-key C-o | |
# reload | |
bind-key r source-file ~/.tmux.conf | |
#按z结束当前会话;相当于进入命令行模式后输入kill-session | |
bind-key z kill-session | |
#按h将当前面板布局切换为even-horizontal;相当于进入命令行模式后输入select-layout even-horizontal | |
#bind-key h select-layout even-horizontal | |
#按v将当前面板布局切换为even-vertical;相当于进入命令行模式后输入select-layout even-vertical | |
#bind-key v select-layout even-vertical | |
#open new window with current path | |
bind-key '"' split-window -c "#{pane_current_path}" | |
bind-key % split-window -h -c "#{pane_current_path}" | |
bind-key c new-window -c "#{pane_current_path}" | |
set -g default-terminal "screen-256color" | |
#更新环境变量当重新打开窗口时 | |
set-option -ga update-environment 'DISPLAY XAUTHORITY DBUS_STARTER_BUS_TYPE DBUS_STARTER_ADDRESS DBUS_SESSION_BUS_ADDRESS WINDOWID SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION' | |
## plugins use 'prefix + I' to fetch | |
# List of plugins | |
# Install: git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
# tmux-yank, depends: xclip or xsel | |
# prefix - y: copy to tmux | |
# copy mode: | |
# y: copy selection to system clipboard | |
# Y: put selection - same as copying a slection, and pasting it to the command line | |
set -g @plugin 'tmux-plugins/tmux-yank' | |
# tmux-copycat | |
# prefix + /: regex search | |
# prefix + C - f: simple file search | |
# prefix + C - g: jumping over git status files(best used after git status) | |
# prefix + M - h: jumping over SHA-1 hashes(best used after git log) | |
# prefix + C - u: url search | |
# prefix + C - d: number search | |
# prefix + M - i: ip address search | |
set -g @plugin 'tmux-plugins/tmux-copycat' | |
# tmux-open | |
# o: open highlighted seclection with system apps | |
# C-o: open highlighted selection with $EDITOR | |
set -g @plugin 'tmux-plugins/tmux-open' | |
#状态栏右方的内容;这里的设置将得到类似23:59的显示 | |
#set-option -g status-right "#(date +%H:%M' ')" | |
#set-option -g status-utf8 on | |
set -g status-bg black | |
set -g status-fg green | |
set -g status-left-length 15 | |
set -g status-left ' #[fg=cyan,bright]#(whoami)#[fg=green]:#[fg=white]#H#[fg=green] | #[default]' | |
set -g status-right '| #[fg=yellow]%y-%m-%d %H:%M ' | |
set -g status-justify centre | |
#状态栏右方的内容长度;建议把更多的空间留给状态栏左方(用于列出当前窗口) | |
#set-option -g status-right-length 10 | |
# 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