算是新年第一彈, 沒(méi)什么新鮮的, 繼續(xù)做個(gè)"小碼農(nóng)"
目錄
tmux是什么
tmux is a "terminal multiplexer", it enables a number of terminals (or windows) to be accessed and controlled from a single terminal
簡(jiǎn)單來(lái)說(shuō)
tmux是一個(gè)終端多窗口管理的效率工具
那么, 除了tmux之外, 還有類似的工具么?
當(dāng)然, 那就是本人一直使用的screen(用法參考這篇文章)
不過(guò), tmux官網(wǎng)指名道姓地說(shuō): tmux就是來(lái)代替screen的! 所以本人也打算轉(zhuǎn)入tmux
tmux is intended to be a simple, modern, BSD-licensed alternative to programs such as GNU screen
tmux中的概念
tmux主要有以下3個(gè)概念需要了解
session: 會(huì)話
window: 窗口
panel: 面板. 可以簡(jiǎn)單理解成"窗口"里的"小窗口"
創(chuàng)建和恢復(fù)會(huì)話就是tmux最大的價(jià)值, 這樣, 無(wú)論何時(shí)何地都可以恢復(fù)終端的工作狀態(tài)
session使用
tmux的Prefix-Command是"ctrl + b", 下面所有的prefix均代表"ctrl + b"
新建: tmux new -s session-name
離開(kāi): prefix d
查看: tmux ls
恢復(fù): tmux attach -t session-name
刪除: tmux kill-session -t session-name
window使用
新建: prefix c
切換: prefix 窗口號(hào)
刪除: prefix &
panel使用
新建: prefix %(左右分割) prefix "(上下分割)
切換: prefix o
刪除: prefix x
進(jìn)階使用
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的習(xí)慣, 習(xí)慣的快捷鍵是"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
參考
更多文章, 請(qǐng)支持我的個(gè)人博客