tmux自定义用户设置(鼠标选项,复制粘贴)

tmux作为一个窗口管理软件,十分方便。但默认的设置一些功能没有打开,添加了相应设置后,功能有所改善,记录一下。

软件版本:tmux 3.4

1. 将终端输入的历史命令保存到文件。

参见https://stackoverflow.com/questions/39368285/can-tmux-save-commands-to-a-file-like-bash-history

由于tmux默认的终端不会将输入的命令保存到.bash_history文件,不方便。而tmux具有history-file选项,需要进行一些配置,打开这个选项,将输入的命令保存到文件。

编辑.tmux.conf文件,加入这一行

set -g history-file ~/.tmux_history
这样就可以将输入的历史命令保存到文件中了。(对于2.1以后的版本有效,对于之前的版本,参见https://unix.stackexchange.com/questions/26548/write-all-tmux-scrollback-to-a-file)
 
2. 设置鼠标模式

set -g mouse on
set -g mouse-select-pane on

对于高于2.1的版本

setw -g mouse on

3. 关于tmux窗口打开后bash_history无法保存的问题。修改~/.bashrc文件添加下面内容
参考https://stackoverflow.com/questions/77492766/save-tmux-daily-history
## Issues with tmux history
# avoid duplicates..
export HISTCONTROL=ignoredups:erasedups
# append history entries:
shopt -s histappend
# After each command, save and reload history:
export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"
 
vim内置的特性
让复制/粘贴更容易,可以在其他选项卡打开,
修改.tmux.conf文件
# vim
setw -g mode-keys vi
bind [ copy-mode
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection
bind -t vi-copy V rectangle-toggle
bind ] paste-buffer

# buffer
bind Space choose-buffer
 
.tmux.conf

 

 
posted @ 2024-07-21 05:20  chinagod  阅读(8)  评论(0编辑  收藏  举报