linux下的多窗口程序sceen的使用简介

转自http://gentoo-wiki.com/TIP_Using_screen

在图形界面下,一个桌面可以有许多窗口,在控制台下也可以实现。

命令简介:


Quick walk-through

       Command                                                          Effect

screen                 Login and start a Screen session right away

C-a "                  Show list of terminals managed by Screen; Here: only one

Esc                    Close the list window

C-a c                  Create a new terminal window

C-a "                  The list of terminals now shows two entries

Esc                    Close the list window

ls                     show the directory contents in this window

C-a p                  return to the previous, first window

ping forums.gentoo.org Do something in this window, too

C-a c                  Create another window

C-a S                  Split the term vertically into two regions

C-a X                  Kill the current region

C-a <Tab>              Focus the newly created region

C-a -                  Resize this region and make it 3 lines smaller

C-a 1                  Show the first window in this region

C-a <Tab>              Move the focus back to the upper region

C-a d                  Detach the Screen session

                       open a xterm

screen -DR             login again and make Screen re-attach (R) to the first session found, after detaching (D) the session

                       first, if necessary (which it wasn't)

 

下面还有动画演示。

 Seeing is believing

An animation of Screen's usage

Enlarge

An animation of Screen's usage

This animated .gif shows most basic commands in a sequence of 50 pictures. This is a transcript of all typed keystrokes:

xterm<Enter>

screen<Enter>

C-a "

<Esc>

C-a c

C-a "

<Esc>

ping forums.gentoo.org<Enter>

C-a n

ls -la<Enter>

C-a S

C-a <Tab>

C-a 1

C-a <Tab>

C-a +

C-a :resize 18<Enter>

C-a x

password

C-a d

screen -ls<Enter>

screen -R<Enter>

printf 'GET / HTTP/1.0\n\n' | telnet forums.gentoo.org 80<Enter>

C-a <Esc>

<PageUp>

<ArrowKeys>

<Space>

<ArrowKeys>

<Space>

C-a c

lynx C-a ]

Exiting Screen

One way to close a Screen session is to exit all terminal sessions you are running inside, one after the other. After the last exit inside Screen you will get [screen is terminating] as a confirmation that your Screen session has ended.

However, a simpler and faster way to do the same thing is to use Screen's quit command.

C-a :quit

This will kill all programs running inside the current Screen session and exit the session. If you use this command frequently, it may be useful to create a keybinding in your configuration file:

File: ~/.screenrc

# bind F10 to Screen's quit command

bindkey -k k; quit

See the "INPUT TRANSLATION" section of the Screen manual for details on how to bind function keys (e.g, F1, F2, ...).

One thought on “linux下的多窗口程序sceen的使用简介”

  1. 转自:(http://www.linuxsir.org/bbs/showthread.php?t=74309

       LinuxSir.Org > Linux 发行版讨论区 —— LinuxSir.Org  > Linux 发行版Debian专题  > Screen真是不错

    转到页面...

    回复

     

    主题工具 搜索本主题 主题评分

    旧 03-11-19, 09:55 第 1 帖

    achaoge

     

    achaoge 的头像

     

     

    注册会员 

      注册日期: Aug 2002

      帖子: 636

      精华: 7

     

    标题: Screen真是不错

    我喜欢用成天用xterm,而作一件事就跑去开一个xterm实在是麻烦,而且还要用鼠标点来点去来切换窗口焦点(我用openbox,不是gnome哦),不爽。

    看了看 Debian参考手册,觉得用screen不错,真的不错哦。

    比如说,正在用vi写程序或者正在编译什么东西,哗,X崩溃了,如果你用了screen,不要紧,一切都可以恢复,只要系统没有死掉,就可以用screen -r连上之前你的工作窗口。

    但是,有一个问题,如何动态有效的表示screen窗口的标题呢,默认情况下,每个screen窗口都是n$ bash这个样子的,如果开了七八个(没这么变态吧?),怎么知道哪个窗口是在干什么呢?不要紧,试试下面的招数:

    我用的是bash,所以:

    拷贝一个screenrc(locate screenrc)到你的用户目录下,在其中加上shelltitle "$ |sh", 这样就可以显示你当前正在执行的程序了。

    我还要切换用户,到不同的目录干活,所以还在我的 .bashrc里头加上了这个:

    # set for screen window title

    if [ "$TERM" = "screen" ] ; then

    export PROMPT_COMMAND='a=`pwd`;echo -e -n ^[k`whoami`@`basename $a`^[\\";unset a'

    fi

    #注意,^[指的是<esc>键,简单拷贝以上语句是不能用的,用C-v-esc才可以输入 ^[

    这样每个screen的窗口标题是就是如下

    0*$ gaochao@lib 1-$ root@data 2$ www-data@egroupware

    是不是很明了?

      发 MSN 消息给 achaoge achaoge 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    achaoge

    查看公开信息

    发悄悄话给 achaoge

    查找 achaoge 发表的更多帖子

    添加 achaoge 到好友列表

    旧 03-11-19, 09:58 第 2 帖

    fireworks

     

     

     

    注册会员 

      注册日期: Nov 2003

      帖子: 205

      精华: 1

     

    i like multi-gnome-terminal & konsole..

      fireworks 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    fireworks

    查看公开信息

    发悄悄话给 fireworks

    查找 fireworks 发表的更多帖子

    添加 fireworks 到好友列表

    旧 03-11-19, 10:07 第 3 帖

    elecboy

     

    elecboy 的头像

     

     

    注册会员 

      注册日期: Oct 2002

      我的住址: 北京

      帖子: 329

      精华: 1

     

    screen 和gnome-terminal及其它一般term不同的,比如你登陆到远程服务器维护,运行一个前台程序(比如编译内核),由于某种原因,你需要暂时退出登陆,但又需要保留现场,不中断运行。这种情况下用screen,就可以很好的解决这个问题。换一台终端后,仍然可以恢复现场。

    __________________

    哆哆嗦,哆哆嗦,今天冻死我,明天就垒窝。

      elecboy 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    elecboy

    查看公开信息

    发悄悄话给 elecboy

    查找 elecboy 发表的更多帖子

    添加 elecboy 到好友列表

    旧 03-11-19, 10:19 第 4 帖

    tram

     

    tram 的头像

     

     

    ★☆★版☆主★☆★ 

      注册日期: Sep 2002

      帖子: 7,314

      精华: 28

     

    这个关键是要服务器上有screen才行啊.

    __________________

    LFS全套中文文档:http://lfs.linuxsir.org(主力)

    LFS 英文站点镜像:http://lfs.cosoft.org.cn

    二笔输入法 for Linux: http://ebf.cosoft.org.cn

      tram 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    tram

    查看公开信息

    发悄悄话给 tram

    访问 tram 的个人网站

    查找 tram 发表的更多帖子

    添加 tram 到好友列表

    旧 03-11-19, 10:26 第 5 帖

    elecboy

     

    elecboy 的头像

     

     

    注册会员 

      注册日期: Oct 2002

      我的住址: 北京

      帖子: 329

      精华: 1

     

    那是当然得装了。

    __________________

    哆哆嗦,哆哆嗦,今天冻死我,明天就垒窝。

      elecboy 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    elecboy

    查看公开信息

    发悄悄话给 elecboy

    查找 elecboy 发表的更多帖子

    添加 elecboy 到好友列表

    旧 04-04-04, 18:34 第 6 帖

    sunyb

     

     

     

    注册会员 

      注册日期: Aug 2003

      帖子: 289

      精华: 0

     

    在gnome-terminal里起动screen,怎么没有楼主说的

    那些效果,难道这些效果是xterm特有的吗?

      sunyb 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    sunyb

    查看公开信息

    发悄悄话给 sunyb

    查找 sunyb 发表的更多帖子

    添加 sunyb 到好友列表

    旧 04-04-05, 09:19 第 7 帖

    achaoge

     

    achaoge 的头像

     

     

    注册会员 

      注册日期: Aug 2002

      帖子: 636

      精华: 7

     

    标题: gnome-terminal也可以啊

    刚刚试过了,应该和terminal无关吧。

    __________________

    首先声明:我用的可是sid

    Debian新手可以参考 Debian 参考手册 (or apt-get install debian-reference-zh-cn)

    Debian安装应该看 Debian安装手册

      发 MSN 消息给 achaoge achaoge 当前离线 向版主反映此帖   回复时引用此帖 快速回复此帖

    achaoge

    查看公开信息

    发悄悄话给 achaoge

    查找 achaoge 发表的更多帖子

    添加 achaoge 到好友列表

    旧 04-04-05, 10:30 第 8 帖

    sunyb

     

     

     

    注册会员 

      注册日期: Aug 2003

      帖子: 289

      精华: 0

     

    把shelltitle "$ |sh"写到~/.screenrc, 在gnome-terminal里敲screen,

    感觉gnome-terminal根本没有任何变化.

    楼主讲得"这样就可以显示你当前正在执行的程序了",这句话是什么意思?

Comments are closed.