tmux配置文件

tmux配置文件

配置文件位置

tmux默认配置文件为~/.tmux.conf,即在当前用户的主目录下,如果没有可以自己创建:

touch ~/.tmux.conf

配置文件加载

在修改完配置文件内容后需要运行如下命令加载配置文件使之生效:

tmux source-file ~/.tmux.conf

也可以在tmux任意窗口中按下快捷键CTRL+B :,在窗口下方光标闪烁,输入source-file ~/.tmux.conf

常用配置

# 设置Shell
set-option -g default-shell /bin/zsh

# 设置复制模式,空格开始选,Enter结束复制
setw -g mode-keys vi 

#开启status-bar uft-8支持
set -g status-utf8 on

# 设定窗口起始
set -g base-index 1

# history
set-option -g history-limit 4096

#urxvt tab like window switching (-n: no prior escape seq)
#ruxvt标签式窗口切换
bind -n S-down new-window
bind -n S-left prev
bind -n S-right next
bind -n C-left swap-window -t -1
bind -n C-right swap-window -t +1

# 切换panes
bind-key C-l last-pane

# 设置鼠标能够操做|滚动设置
#   --> 使用shift键+鼠标键选择文件,Ctrl+Shift+C复制,Ctrl+Shift+V粘贴
# set -g mode-mouse on
# set -g mode-mouse off  # --> let cygwin mouse can be used.
# disable mouse control by default - change 'off' to 'on' to enable by default.
setw -g mode-mouse off
set-option -g mouse-resize-pane off
set-option -g mouse-select-pane off
set-option -g mouse-select-window off
# toggle mouse mode to allow mouse copy/paste
# set mouse on with prefix m
bind m \
    set -g mode-mouse on \;\
    set -g mouse-resize-pane on \;\
    set -g mouse-select-pane on \;\
    set -g mouse-select-window on \;\
    display 'Mouse: ON'
# set mouse off with prefix M
bind M \
    set -g mode-mouse off \;\
    set -g mouse-resize-pane off \;\
    set -g mouse-select-pane off \;\
    set -g mouse-select-window off \;\
    display 'Mouse: OFF'

# 设置窗口可自动调整index
set -g renumber-windows on

# 复制和粘贴模式的快捷键
bind y copy-mode
bind c-y copy-mode
bind p paste-buffer
bind c-p paste-buffer

# Toggle log to file
bind H pipe-pane -o 'cat >>$HOME/#W-tmux.log' '\;' display-message 'Toggled logging to $HOME/#W-tmux.log'

bind h pipe-pane \; display-message 'Ended logging to $HOME/#W-tmux.log'

# 设置窗口名字不能修改
set-option -g allow-rename off

# 设置启动窗口时默认名字
# bind-key c new-window -n 'zsh'

# 设置r键为加载配置文件,并提示信息
bind r source-file ~/.tmux.conf \; display "配置文件已从新加载!" 

# other
setw -g xterm-keys on

#------------------------------------------------------------------------------#
#  *** 基本终终端操做 ***
#  tmux new -s "session_name"       // 建立一个seesion
#  tmux new -s "session_name" -d    // 建立一个seesion, 并在后台运行
#  tmux ls                          // 列出tmux会话列表
#  tmux attach -t session           // 进入指定的会话(可终端共享)
#  tmux kill-session -t "session"   // 删除指定会话
#
#  ** 容易混淆 **
#  bind-key ;   // switch to last pane
#  bind-key l   // switch to last window
#  bind-key L   // switch to last session
#  bind-key C-l // switch to last pane(like: bind-key ;)
#
#  *** 控制台-操做说明 ***
#  Ctrl+b  // 激活控制台
#  ** 系统操做   
#      ?   // 列出全部快捷键;按q返回   
#      d   // 脱离当前会话;
#      D   // 选择要脱离的会话;在同时开启了多个会话时使用   
#      Ctrl+z  // 挂起当前会话   
#      r   // 强制重绘未脱离的会话   
#      s   // 选择并切换会话;在同时开启了多个会话时使用   
#      :   // 进入命令行模式;
#               :new-session         // 建立新会话
#      [   // 进入复制模式;此时的操做与vi/emacs相同,按q/Esc退出   
#      ]   // 进入粘贴模式;
#      ~   // 列出提示信息缓存;其中包含了以前tmux返回的各类提示信息   
#
#  ** 会话操做
#      (   preview session
#      )   next session
#      L   last session
#      s   list session
#      $   rename seesion
#
#  ** 窗口操做
#      c   // 建立新窗口   
#      &   // 关闭当前窗口   
#      [0-9] // 切换至指定窗口   
#      p   // 切换至上一窗口   
#      n   // 切换至下一窗口   
#      l   // 在先后两个窗口间互相切换   
#      w   // 经过窗口列表切换窗口   
#      ,   // 重命名当前窗口;这样便于识别   
#      .   // 修改当前窗口编号;至关于窗口从新排序   
#      f   // 在全部窗口中查找指定文本   
#      i   // 显示tmux当前信息
#
#  ** 面板操做   
#      ”   // 将当前面板平分为上下两块|横向切割 --> 分割成面板
#      %   // 将当前面板平分为左右两块|竖向切割 --> 分割成面板
#      x   // 关闭当前面板   
#      ;   // 切换到最后的pane
#      !   // 将当前面板置于新窗口;即新建一个窗口,其中仅包含当前面板   
#      Ctrl+方向键  // 以1个单元格为单位移动边缘以调整当前面板大小   
#      Alt+方向键   // 以5个单元格为单位移动边缘以调整当前面板大小   
#      Space        // 在预置的面板布局中循环切换;依次包括:
#                       even-horizontal、
#                       even-vertical、
#                       main-horizontal、
#                       main-vertical、
#                       tiled   
#      q   // 显示面板编号   
#      o   // 在当前窗口中选择下一面板   
#      {   // 向前置换当前面板   
#      }   // 向后置换当前面板   
#      方向键   // 移动光标以选择面板   
#      Alt+o    // 逆时针旋转当前窗口的面板   
#      Ctrl+o   // 顺时针旋转当前窗口的面板   


#  *** 参考配置 ***
#
#  ** 配置1 **
#  #设置pan前景色  
#  set -g pane-border-fg green  
#  #设置pane背景色  
#  set -g pane-border-bg black 
#  #设置终端颜色为256色
#  set -g default-terminal "screen-256color"
#  #开启status-bar uft-8支持
#  set -g status-utf8 on
#  #设置pan前景色
#  set -g pane-border-fg green
#  #设置pane背景色
#  set -g pane-border-bg black
#  #设置活跃pane前景色
#  set -g pane-active-border-fg white
#  #设置活跃pane背景色
#  set -g pane-active-border-bg yellow
#  #设置消息前景色
#  set -g message-fg white
#  #设置消息背景色
#  set -g message-bg black
#  #设置消息高亮显示
#  set -g message-attr bright
#  #设置status-bar颜色
#  set -g status-fg white
#  set -g status-bg black
#  #设置窗口列表颜色
#  setw -g window-status-fg cyan
#  setw -g window-status-bg default
#  setw -g window-status-attr dim
#  #设置当前窗口在status bar中的颜色
#  setw -g window-status-current-fg white
#  setw -g window-status-current-bg red
#  setw -g window-status-current-attr bright
#  #设置status bar格式
#  set -g status-left-length 40
#  set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
#  set -g status-right "#[fg=cyan]%d %b %R"
#  set -g status-interval 60
#  set -g status-justify centre
#  #开启window事件提示
#  setw -g monitor-activity on
#  set -g visual-activity on
#
#  ** 配置2 **
#  # 同一个窗口中的面板操做
#  # up
#  bind-key k select-pane -U 
#  #down
#  bind-key j select-pane -D
#  #left
#  bind-key h select-pane -L
#  #right
#  bind-key l select-pane -R
#  #select last window
#  bind-key C-l select-window -l
#------------------------------------------------------------------------------#
  • 7
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要下载tmux配置文件,你可以按照以下步骤进行操作: 1. 首先,确保你的系统上已经安装了tmux。你可以使用包管理器(如apt、yum或brew)来安装tmux。例如,在Ubuntu上,你可以运行以下命令来安装tmux: ``` sudo apt-get install tmux ``` 2. 接下来,下载配置文件。你可以在Github等代码托管平台上找到很多现成的tmux配置文件。你可以根据自己的需求选择一个合适的配置文件。例如,你可以在Github上搜索“tmux config”并浏览搜索结果。 3. 找到一个适合你的配置文件后,你可以直接下载它。在Github上,你可以点击绿色的“Code”按钮,然后选择“Download ZIP”,将配置文件的zip包下载到你的本地。 4. 解压缩下载的zip包。你可以使用archive工具(如WinRAR、7-Zip)来解压缩文件。解压缩后,你会得到一个包含配置文件的文件夹。 5. 找到tmux配置文件。在解压缩后的文件夹中,你可能会找到一个或多个文件,带有`.tmux.conf`、`.tmux`或`tmux.conf`的名称。选择其中一个文件,并将其命名为`.tmux.conf`。 6. 将配置文件放置在正确的位置。将`.tmux.conf`文件复制到你的用户目录下(在Linux和macOS中为`~`,在Windows中为`C:\Users\你的用户名`)。 7. 然后,打开终端,并重新启动tmux。你将看到新应用的配置已经生效。 通过遵循以上步骤,你可以方便地下载并使用tmux配置文件。记得在使用之前备份你的现有配置文件,以防止出现问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值