树莓派配置记录——tmux
tmux是一个linux的命令行分屏工具。将一个屏幕划分为多个区域,可以同时运行不同的程序。自从发现tmux以后,才在命令行下充分发挥了Linux的多进程,不再需要巨卡的树莓派桌面了,一个putty走天下
我的tmux的配置文件(~/.tmux.conf)如下
#可以用鼠标动态拖动区域的分割线。缺点是tmux的鼠标选区复制受到影响,只能用putty的shift+左键选区复制功能。而putty的选取是横跨整个屏幕,不支持垂直分割的区域,复制以后需要手动调整 set -g mouse on #缓存10000行历史,不怕刷屏 set -g history-limit 10000 #ctrl+b,r立刻应用配置文件的修改 bind r source ~/.tmux.conf \; display "Configuration reloaded!"
#设置bash为默认的shell set -g default-shell /bin/bash
#F2可以给窗口重命名 bind -n F2 command-prompt 'rename-window %%'
#ctrl+b, v/h垂直/水平切分窗口 bind v split-window -v
bind h split-window -h
#先右键选择一个窗口,再切换到目标窗口后按ctrl+b, V/H垂直/水平合并窗口 bind V join-pane -v
bind H join-pane -h
#设置颜色 set -g default-terminal "screen-256color"
set -g window-style 'fg=colour248,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'
set -g pane-border-style 'fg=colour66,bg=colour236'
set -g pane-active-border-style 'fg=colour51,bg=black'
set -g status-position top
set -g status-fg colour15
set -g status-bg colour17
set -g window-status-style 'bg=colour66'
set -g window-status-current-style 'bg=colour33'
另外,tmux可能无法显示彩色,需要在.bashrc最后添加一句:
export TERM=xterm-256color
或者在用putty连接的时候,将Connection -- Data -- Terminal-type string改为 xterm-256color
常用的tmux按键
先按Ctrl+B进入命令模式,再按具体的键
Ctrl+B,v——垂直分屏(%为默认按键)
Ctrl+B,h——水平分屏("为默认按键)
Ctrl+B,!——将当前小窗口移动到一个新建的大窗口
Ctrl+B,x——关闭当前区域
Ctrl+B,d——保存分屏,退出tmux。退出以后在命令行输入 tmux a,就可以恢复退出前的分屏状态。重启则保存无效。。。
小脚本用于测试颜色
1 #!/bin/bash 2 3 # This program is free software. It comes without any warranty, to 4 # the extent permitted by applicable law. You can redistribute it 5 # and/or modify it under the terms of the Do What The Fuck You Want 6 # To Public License, Version 2, as published by Sam Hocevar. See 7 # http://sam.zoy.org/wtfpl/COPYING for more details. 8 9 for fgbg in 38 48 ; do # Foreground / Background 10 for color in {0..255} ; do # Colors 11 # Display the color 12 printf "\e[${fgbg};5;%sm %3s \e[0m" $color $color 13 # Display 6 colors per lines 14 if [ $((($color + 1) % 6)) == 4 ] ; then 15 echo # New line 16 fi 17 done 18 echo # New line 19 done 20 21 exit 0
测试结果


浙公网安备 33010602011771号