tmux
tmux准备:tmux既可以进行远程session的管理,即使ssh断开,程序还会继续运行,以前跑实验要跑半个月的时候都是使用screen,可以防止网络断了程序跑一半的情况,现在发现tmux更强大。 session新建session,如果没有-s,会以数字0,1,2...命名: $ tmux new -s test 列出当前可用的session: $ tmux ls test: 1 windows (created Fri May 10 10:05:32 2019) [158x32] zsh: 1 windows (created Fri May 10 09:50:32 2019) [158x32] detach,使用命令detach-client(可以简写为detach或det),直接关掉gnome-terminial也会自动detach: prefix + d tmux detach # detach当前tmux session tmux detach -s test 连接session, 命令是attach-session(可以简写为attach或a): tmux a -t test 如果session在其它地方被使用,可以使用-d在连接的同时,detach掉其它地方的连接,如果不detach掉的话,这边的修改同时也会同步到其它地方: tmux a -d -t test 列表显示所有session: prefix + a window新建window prefix + c 切换到下一个window: prefix + n 切换到上一个window: prefix + p 切换到指定window: prefix + window的编号(如第0个窗口就是0) 关闭当前window prefix + x 列表显示当前window: prefix + w 修改当前窗口名称,以方便记住: prefix +, panelpanel是tmux最具特色的功能,它可以在一个界面中显示多个shell操作界面。 左右分屏: prefix + | 上下分屏: prefix + - 切换到下一个分屏: prefix + o 切换: prefix + ijlk 最大化显示当前panel,很好用,再操作一次返回以前状态: prefix + z 问题tmux有个痛点,也是我一度抛弃tmux的原因。那就是鼠标滚屏与鼠标选中中键复制功能不能兼得。
配置文件tmux配置文件位置~/.tmux.conf: set -g prefix ^a
unbind ^b
bind a send-prefix
setw -g mode-keys vi
set -g base-index 1
#水平或垂直分割窗口
unbind ‘"‘
bind - splitw -v -c "#{pane_current_path}" # 分割成上下两个窗口
unbind %
bind | splitw -h -c "#{pane_current_path}" # 分割成左右两个窗口‘"‘
bind c new-window -c "#{pane_current_path}"
# 开启鼠标模式
set-option -g mouse on
# 允许鼠标选择窗格
setw -g mouse on
#set -g mouse-select-pane on
# 如果喜欢给窗口自定义命名,那么需要关闭窗口的自动命名
#set-option -g allow-rename off
# Scroll History
set -g history-limit 30000
# Set ability to capture on start and restore on exit window data when running an application
setw -g alternate-screen on
# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
# 如果对 vim 比较熟悉,可以将 copy mode 的快捷键换成 vi 模式
set-window-option -g mode-keys vi
bind Escape copy-mode
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection
unbind [
#unbind p
#bind p paste-buffer
#选择分割的窗格
bind k selectp -U # 选择上窗格
bind j selectp -D # 选择下窗格
bind h selectp -L # 选择左窗格
bind l selectp -R # 选择右窗格
#重新调整窗格的大小
bind ^k resizep -U 10 # 跟选择窗格的设置相同,只是多加 Ctrl(Ctrl-k)
bind ^j resizep -D 10 # 同上
bind ^h resizep -L 10 # ...
bind ^l resizep -R 10 # ...
#交换两个窗格
bind ^u swapp -U # 与上窗格交换 Ctrl-u
bind ^d swapp -D # 与下窗格交换 Ctrl-d
# 状态栏设置
# status bar with load and time
set -g status-bg blue
set -g status-fg ‘#bbbbbb‘
set -g status-left-fg green
set -g status-left-bg blue
set -g status-right-fg green
set -g status-right-bg blue
set -g status-left-length 90
set -g status-right-length 90
set -g status-left ‘[#(whoami)]‘
set -g status-right ‘[#(date +" %m-%d %H:%M ")]‘
#set -g status-justify "centre"
set -g window-status-format ‘#I #W‘
set -g window-status-current-format ‘ #I #W ‘
setw -g window-status-current-bg blue
setw -g window-status-current-fg green
set -g default-terminal "screen-256color"
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Haskell:Arch Linux上缺少的C库适用于Ubuntu
- 最大化时tmux条和终端窗口底部之间的恼人填充
- linux – 如何使用pam配置错误消息修复crontab访问问题?
- 任务1:Linux Kernel提权(50分)[2019年信息安全管理与评估
- Linux无法解释ACK,不断重新发送SYN ACK
- Linux RAID磁盘列阵完全攻略
- linux – 结合HBase和HDFS会在makeDirOnFileSystem中导致异
- 如何在NFS分区和本地分区中的工作树中安装git存储库?
- Instances cannot be resolved and nested lifetimes canno
- 调试 – 为什么核心文件不仅仅是虚拟内存?