tmux

算是新年第一弹, 没什么新鲜的, 继续做个"小码农"

目录

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

参考

更多文章, 请支持我的个人博客

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容