美文网首页
Tmux使用

Tmux使用

作者: Shad0wpf | 来源:发表于2019-12-10 19:04 被阅读0次

创建新会话

tmux new -s Test

查看会话

tmux list-sessions

连接已有会话

tmux attach -t Test

tmux attach -t Test -r   #只读模式

断开会话

Ctrl + b, d

会话中的窗口操作

前缀按键,默认为Ctrl + b,以下命令,先按前缀键后再执行

命令 功能
c 创建新窗口
, 重命名当前窗口
0-9 切换窗口(下面有窗口编号,当前窗口后面有* )
( / p 切换到前一个窗口
) / n 切换到后一个窗口
d 分离当前客户端
L 切换会话
i 显示当前窗口信息
% 垂直分割窗口
" 水平分割窗口
方向键 切换窗格
空格 调整窗格排列方式
{/} 交换窗格
Ctrl + 方向键 调整窗口分割线
x 关闭当前窗格
z 最大化当前窗格(窗口名称后会添加*Z)
t 显示时间

Tmux插件

Oh My Tmux!

Pretty & versatile tmux configuration made with ❤️ (imho the best tmux configuration that just works)
Github:https://github.com/gpakosz/.tmux

默认没有~/.tmux.conf文件,Oh My Tmux是一套优化好的tmux配置。

  • 安装
    Requirements:
    tmux >= 2.1 running inside Linux, Mac, OpenBSD, Cygwin or WSL (Bash on Ubuntu on Windows)
    outside of tmux, $TERM must be set to xterm-256color
    To install, run the following from your terminal: (you may want to backup your existing ~/.tmux.conf first)
cd ~
git clone https://github.com/gpakosz/.tmux.git
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .

tmux-plugin-manager

Github:https://github.com/tmux-plugins/tpm
使用apt安装

apt install tmux-plugin-manager

安装路径为/usr/share/tmux-plugin-manager

使用apt或克隆源码后,编辑~/.tmux.conf文件,添加以下几行内容:

#List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

#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 (添加到.tmux.conf文件最后一行)
run -b 'usr/share/tmux-plugin-manager/tpm'

tmux-logging

Github:https://github.com/tmux-plugins/tmux-logging

  • 使用TPM安装 (推荐该方式)
    编辑~/.tmux.conf文件,增加一行:
set -g @plugin '/tmux-plugins/tmux-logging'

然后进入Tmux,按prefix + I 刷新插件,tpm会自动下载该插件。

  • 使用:
  1. 记录日志
    Toggle (start/stop) logging in the current pane.
    快捷键:prefix + shift + p
    File name format: tmux-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
    File path: $HOME (user home dir)
    Example file: ~/tmux-my-session-0-1-20140527T165614.log

  2. 截屏
    Save visible text, in the current pane. Equivalent of a "textual screenshot".
    快捷键:prefix + alt + p
    日志文件名格式: tmux-screen-capture-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
    文件保存路径: $HOME (user home dir)

NOTE: this functionality depends on the value of history-limit - the number of lines Tmux keeps in the scrollback buffer. Only what Tmux kept will also be saved, to a file.
Use set -g history-limit 50000 in .tmux.conf, with modern computers it is ok to set this option to a high number.

  1. 清除pane历史记录
    快捷键:prefix + alt + c

修改日志条数

#increase history size
set -g history-limit 10000

搜索、选择、复制

Ctrl-b + [,进入选择模式,可以设置VI的搜索快捷键进行搜索,按空格开始选择,按回车确认选择内容
Ctrl-b + ], 粘贴选择的内容

使用VI搜索快捷键

编辑~/.tmux.conf,添加一行内容:

# Use vim keybindings in copy mode
setw -g mode-keys vi

复制内容到系统剪贴板

# -- clipboard -----------------------------------------------------------------

# in copy mode, copying selection also copies to the OS clipboard
#   - true
#   - false (default)
# on macOS, this requires installing reattach-to-user-namespace, see README.md
# on Linux, this requires xsel or xclip

tmux_conf_copy_to_os_clipboard=true

支持鼠标模式

# start with mouse mode enabled
set -g mouse on

Xshell中,开启鼠标模式后,按住Shift点击邮件,调出Xshell的右键菜单。

配置文件

.tmux.conf

相关文章

  • Tmux 使用笔记

    Tmux 速成教程:技巧和调整Tmux 入门介绍多终端管理器TMUX使用详解 查看tmux版本 tmux -V 会...

  • tmux的分屏功能、会话不中断功能

    1)安装工具 在ubuntu系统中安装tmux工具 (2)使用tmux 分屏命令 1. 输入命令 tmux 使用...

  • tmux使用介绍

    tmux简介 tmux,升级版本的screen,可以进行屏幕切割,操作更加简单便捷。 tmux模块 tmux使用C...

  • 公司网络不好试试Tmux

    同事分享的很棒的工具: Tmux 使用 1. Tmux是什么 1.1 Tmux的作用 命令行的典型使用方式是,打开...

  • tmux分屏

    在ubuntu系统中使用sudo apt-get install tmux安装tmux工具 1,输入命令tmux使...

  • Alacritty 与 tmux 按键冲突

    问题 Alacritty 占用了 tmux 的前缀键导致 tmux 无法使用 解决 Alacritty 使用 he...

  • tmux和vim很配哦:使用vim风格的快捷键

    tmux快捷键 tmux默认使用emacs模式的快捷键,这对我们使用vim的用户其实很不友好,而且我们认为tmux...

  • 2020-02-21 git 和 tmux

    1. tmux tmux的使用和配置 tmux使用手册 2. git 猴子都能看懂的git入门-git索引 git...

  • tmux使用教程

    Tmux使用手册:http://louiszhai.github.io/2017/09/30/tmux/

  • Tmux 简单使用方法

    安装 Tmux 一般的云主机都不会带有Tmux,需要自己安装 使用 Tmux 直接在命令行输入tmux,就进入Tm...

网友评论

      本文标题:Tmux使用

      本文链接:https://www.haomeiwen.com/subject/fioggctx.html