如何使用tmux工具快捷键自定义

前言:

Tmux是一个终端复用工具(terminal multipler),在我们工作中经常需要编译安卓或者大型工程时需要ssh远程到服务器编译,一但使用远程的电脑断掉ssh连接(休眠、关机、重启、关掉ssh 连接等)

使用ssh登录的操作编译、vim等工作状态就随着ssh 会话结束而断掉。使用tmux工具,可以做到窗口与ssh会话的进进程解绑,可以保留当前的会话的工作继续运行。

一、tmux工具配置

1.1 配置文件内容

代码块标题

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

# vim: set ft=tmux:

set -g base-index 1

# default window for session cmd

new-session -s cmd

new-window -d -t cmd:

new-window -d -t cmd:

new-window -d -t cmd:

new-window -d -t cmd:

# set prefix to `

unbind-key C-b

set-option -g prefix `

# press ` for 2 times to get `

bind ` send-prefix

# use ; for command prompt

unbind :

unbind \;

bind \; command-prompt

# screen like binding

unbind x

bind k confirm-before kill-pane

unbind [

bind Escape copy-mode

setw -g mode-keys vi

setw -g xterm-keys on

unbind %

unbind c

bind c new-window -c "#{pane_current_path}"

bind _ split-window -c "#{pane_current_path}"

bind | split-window -h -c "#{pane_current_path}"

# update "terminal window" title

set-option -g set-titles on

# I rely on zsh to rename window title

setw -g automatic-rename off

set-option -g visual-activity on

setw -g monitor-activity on

# prevent application like less, vim clear screen after exit

set-window-option -g alternate-screen off

setw -g utf8 on

set -g terminal-overrides "*88col*:colors=88,*256col*:colors=256,xterm*:colors=256"

set -g default-terminal "screen-256color"

#set -g default-terminal "xterm"

set -g status-utf8 on

set -g status-justify centre

set -g status-bg default

set -g status-left "#[fg=red][ #[fg=green]#H #[fg=red]]#[default]"

set -g status-left-length 20

set -g status-right-length 25

set -g status-right "#[fg=red][ #[fg=green]%H:%M #[fg=magenta]%a %m-%d #[fg=red]] #[default]"

setw -g window-status-format '#[fg=blue,bold]#I: #W#F#[default]'

setw -g window-status-current-format '#[fg=yellow,bold,reverse]#I: #W#F#[default] '

set -g encoding utf-8

set -s escape-time 0

配置文件命名为: .tmux.conf

配置文件位置 :$ ~/.tmux.conf   #(/home/usr) 

安装tmux工具命令: sudo apt install tmux

1.2 tmux 工具快捷键

1.2.1 新建窗口分屏操作

基本的使用工具命令:

$tmux   #可以直接进入tmux的窗口界面

$tmux ls #查看看 tmux 会话连接详情

$ tmux new -s xxx  #创建xxx名字会话连接

$tmux attach # 恢复最近的会话

$tmux a -s xxx # 恢复之前打开的名字 xxx的会话

   会话窗口的所有操作都需要先按一下 ~在进行其他操作例如:

~+c   #新建窗口

~+k #关掉当前窗口

~+o  #顺序切换窗口

~+|  #竖排分屏

~+_  #横排分屏

~+数字 #跳到对相应的窗口

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值