screen 是一款 主要问题:
- 基础操作
- 中文乱码
- 无法滚动
基础操作
语法
screen [-AmRvx -ls -wipe][-d <作业名称>][-h <行数>][-r <作业名称>][-s <shell>][-S <作业名称>]
参数说明:
- -A 将所有的视窗都调整为目前终端机的大小。
- -d<作业名称> 将指定的screen作业离线。
- -h<行数> 指定视窗的缓冲区行数。
- -m 即使目前已在作业中的screen作业,仍强制建立新的screen作业。
- -r<作业名称> 恢复离线的screen作业。
- -R 先试图恢复离线的作业。若找不到离线的作业,即建立新的screen作业。
- -s
指定建立新视窗时,所要执行的shell。 - -S<作业名称> 指定screen作业的名称。
- -v 显示版本信息。
- -x 恢复之前离线的screen作业。
- -ls或--list 显示目前所有的screen作业。
- -wipe 检查目前所有的screen作业,并删除已经无法使用的screen作业。
激活screen窗口时的快捷键:
- Ctrl+A,Ctrl+D:离开当前终端
- Ctrl+A,Ctrl+Esc:进入预览模式(可滚动)
中文乱码解决
Step1
普通用户执行【或者说,后续用哪个用户执行screen命令就用哪个用户】:
cat > ~/.screenrc << 'EOF'
shell /bin/bash
# Set default encoding using utf8
defutf8 on
# 解决中文乱码.
defencoding utf8
encoding utf8 utf8
EOF
Step2
root用户执行:
vim /etc/locale.gen
# 编辑文件,去掉zh_CN.UTF-8 UTF-8的注释(我同时去掉了en_US.UTF-8 UTF-8行的注释,不知道有没有什么影响)
locale-gen
滚动问题解决
使用上面的预览模式快捷键,或参考另一个更多配置中的内容
# http://www.gnu.org/software/screen/manual/screen.html
# https://www.kilobitspersecond.com/2014/02/10/understanding-gnu-screens-hardstatus-strings/
# Set default encoding using utf8
defutf8 on
# 解决中文乱码.
defencoding utf8
encoding utf8 utf8
# 兼容shell 使得.bashrc .profile /etc/profile等里面的别名等设置生效
shell -$SHELL
# set the startup message
startup_message off
term linux
# 解决无法滚动
termcapinfo xterm|xterms|xs ti@:te=\E[2J
# 屏幕缓冲区行数
defscrollback 10000
# 下标签设置
hardstatus on
#caption always "%{= kw}%-w%{= kG}%{+b}[%n %t]%{-b}%{= kw}%+w %=%d %M %0c %{g}%H%{-}"
caption always "%{= kw}%-w%{= kG}%{+b}[%n %t]%{-b}%{= kw}%+w %=%Y-%m-%d %{G}%H%{-}"
# turn visual bell off
vbell off
# Automatically detach on hangup.
autodetach on
# If a screen dies, dont freeze the whole screen waiting for it.
# Enable non-blocking mode to better cope with flaky ssh connections.
nonblock on
# default windows
screen -t vim 1
screen -t bash 0
#Keboard binding
#bind Alt+z to move to previous window
bindkey ^[z prev
# bind Alt+x to move to next window
bindkey ^[x next
# bind Alt`~= to screen0~12
bindkey "^[`" select 0
bindkey "^[1" select 1
bindkey "^[2" select 2
bindkey "^[3" select 3
bindkey "^[4" select 4
bindkey "^[5" select 5
bindkey "^[6" select 6
bindkey "^[7" select 7
bindkey "^[8" select 8
bindkey "^[9" select 9
bindkey "^[0" select 10
bindkey "^[-" select 11
bindkey "^[=" select 12
# bind F5 to create a new screen
bindkey -k k5 screen
# bind F6 to detach screen session (to background)
bindkey -k k6 detach
# bind F7 to kill current screen window
bindkey -k k7 kill
# bind F8 to rename current screen window
bindkey -k k8 title
# Remove some stupid / dangerous key bindings
bind ^k
#bind L
bind ^\
# Make them better
bind \\ quit
bind K kill
bind I login on
bind O login off
bind } history


Comments | NOTHING