算是新年第一彈, 沒什么新鮮的, 繼續做個"小碼農"
目錄
tmux是什么
tmux is a "terminal multiplexer", it enables a number of terminals (or windows) to be accessed and controlled from a single terminal
簡單來說
tmux是一個終端多窗口管理的效率工具
那么, 除了tmux之外, 還有類似的工具么?
當然, 那就是本人一直使用的screen(用法參考這篇文章)
不過, tmux官網指名道姓地說: tmux就是來代替screen的! 所以本人也打算轉入tmux
tmux is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen
tmux中的概念
tmux主要有以下3個概念需要了解
session: 會話
window: 窗口
panel: 面板. 可以簡單理解成"窗口"里的"小窗口"
創建和恢復會話就是tmux最大的價值, 這樣, 無論何時何地都可以恢復終端的工作狀態
session使用
tmux的Prefix-Command是"ctrl + b", 下面所有的prefix均代表"ctrl + b"
新建: tmux new -s session-name
離開: prefix d
查看: tmux ls
恢復: tmux attach -t session-name
刪除: tmux kill-session -t session-name
window使用
新建: prefix c
切換: prefix 窗口號
刪除: prefix &
panel使用
新建: prefix %(左右分割) prefix "(上下分割)
切換: prefix o
刪除: prefix x
進階使用
Copy Mode
Enter Copy Mode: prefix [
Go Line in Copy Mode: g line-number
Search in Copy Mode: ctrl + s
Tmux Plugin
修改Prefix-Command
由于之前使用screen的習慣, 習慣的快捷鍵是"ctrl+a", 所以想修改Prefix-Command, 在~/.tmux.conf中配置如下
# shortcuts
set -g prefix C-a
unbind C-b
bind C-a send-prefix
然后然tmux重新加載新的配置
tmux source ~/.tmux.conf
修改其他快捷鍵
unbind n
bind C-a next-window
unbind &
bind k kill-window
我的.tmux.conf文件
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-copycat'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# shortcuts
set -g prefix C-a
unbind C-b
bind C-a send-prefix
unbind n
bind C-a next-window
unbind &
bind k kill-window
參考
更多文章, 請支持我的個人博客