AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 3740
Accepted
Gareth
Gareth
Asked: 2009-05-04 16:17:07 +0800 CST2009-05-04 16:17:07 +0800 CST 2009-05-04 16:17:07 +0800 CST

什么是有用的 .screenrc 设置?

  • 772
锁定。这个问题及其答案被锁定,因为这个问题离题但具有历史意义。它目前不接受新的答案或交互。

基本上就像我在下面发布的一些我自己的。我正在寻找程序“屏幕”的附加功能。至少看一下屏幕会话底部的奇妙“菜单栏”的最后一行。

## gyaresu's .screenrc 2008-03-25
# http://delicious.com/search?p=screenrc

# Don't display the copyright page
startup_message off

# tab-completion flash in heading bar
vbell off

# keep scrollback n lines
defscrollback 1000

# Doesn't fix scrollback problem on xterm because if you scroll back
# all you see is the other terminals history.
# termcapinfo xterm|xterms|xs|rxvt ti@:te@

# These will let you use 
bind -c selectHighs 0 select 10 #these three commands are 
bind -c selectHighs 1 select 11 #added to the command-class
bind -c selectHighs 2 select 12 #selectHighs
bind -c selectHighs 3 select 13
bind -c selectHighs 4 select 14
bind -c selectHighs 5 select 15


bind - command -c selectHighs   #bind the hyphen to 
                                #command-class selectHighs 


screen -t rtorrent  0   rtorrent    
#screen -t tunes        1   ncmpc --host=192.168.1.4 --port=6600 #was for connecting to MPD music server.
screen -t stuff     1
screen -t irssi     2   irssi
screen -t dancing   4       
screen -t python    5   python
screen -t giantfriend   6   these_are_ssh_to_server_scripts.sh
screen -t computerrescue    7   these_are_ssh_to_server_scripts.sh
screen -t BMon      8   bmon -p eth0
screen -t htop      9   htop
screen -t hellanzb  10  hellanzb
screen -t watching  3   
#screen -t interactive.fiction  8
#screen -t hellahella   8   paster serve --daemon  /home/gyaresu/downloads/hellahella/hella.ini 

shelltitle "$ |bash"

# THIS IS THE PRETTY BIT
#change the hardstatus settings to give an window list at the bottom of the                                                                        
##screen, with the time and date and with the current window highlighted                                                                            
hardstatus             alwayslastline                                                                                                                          
#hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'

linux bash command-line-interface gnu-screen dotfiles
  • 12 12 个回答
  • 122320 Views

12 个回答

  • Voted
  1. Best Answer
    Hamish Downer
    2009-05-05T03:22:17+08:002009-05-05T03:22:17+08:00

    对于那些想要以不那么神秘的方式来设置漂亮屏幕的人,我可以衷心推荐byobu(以前称为屏幕配置文件)。它在屏幕底部为您提供了一组很好的默认内容 - 底行包含各种方便的状态信息,底行第二个包含您的屏幕窗口列表。所有这些都可以通过按 F9 在一个漂亮的简单 ncurses 菜单中进行配置。

    功能键映射到常用操作:

    • F2 - 创建一个新窗口
    • F3 - 转到上一个窗口
    • F4 - 转到下一个窗口
    • F5 - 重新加载配置文件
    • F6 - 从会话中分离
    • F7 - 进入回滚模式
    • F8 - 查看所有键绑定
    • F9 - 配置屏幕配置文件
    • F12 - 锁定此终端

    有关教程和屏幕截图,请参阅这篇文章。

    Byobu 从 karmic (9.10) 开始就在 ubuntu 存储库中。在活泼的情况下,它被称为屏幕配置文件。在此之前,它可以从这个下载页面的这个 ppa安装。它也被广泛打包用于其他最新的发行版。

    它确实依赖于 python,但是一旦您按照自己的喜好设置了 byobu,您就可以让它生成一个 tar 球,其中包含使用byobu-export在另一台计算机上重新创建屏幕所需的所有内容。

    • 22
  2. rampion
    2009-05-04T18:41:00+08:002009-05-04T18:41:00+08:00

    我还使用了相当复杂的标题/hardstatus 行组合,来模拟下拉选项卡的效果(标题行是纯灰色,hardstatus 中的当前选项卡是相同的颜色)。

    我还让我的 shell 告诉屏幕当前进程名称是什么以及我所在的目录,因此我的选项卡名称与我在每个选项卡中所做的事情保持同步。这对于记住我在哪里做的事情至关重要,而无需浏览所有打开的标签。

     # don't use the hardstatus line for system messages, use reverse video instead
     # (we'll be using it for the list of tab windows - see hardstatus alwayslastline
     # below)
     hardstatus off
    
     # use the caption line for the computer name, load, hstatus (as set by zsh), & time
     # the caption line gets repeated for each window being displayed (using :split),
     # so we'll use color cues to differentiate the caption of the current, active
     # window, and the others.
     #    always                  - display the caption continuously.  Since
     #                              hardstatus is 'alwayslastline', it will be on the
     #                              next to last line.
     #    "%?%F"                  - if (leading '%?') this region has focus ('%F') 
     #                              (e.g. it's the only region being displayed, or,
     #                              if in split-screen mode, it's the currently active
     #                              region)
     #      "%{= Kk}"               - set the colorscheme to blac[k] on grey (bright blac[K]),
     #                                with no other effects (standout, underline, etc.)
     #    "%:"                    - otherwise ('%:' between a pair of '%?'s)
     #      "%{=u kR}"              - set the colorscheme to [R]ed on blac[k], and
     #                                underline it, but no other effects (bold, standout, etc.) 
     #    "%?"                    - end if (trailing '%?')
     #    "  %h "                 - print two spaces, tthne the [h]ardstatus of the
     #                              current tab window (as set by zsh - see zshrc) and
     #                              then another space.
     #    "%-024="                - either pad (with spaces) or truncate the previous
     #                              text so that the rest of the caption string starts
     #                              24 characters ('024') from the right ('-') edge of
     #                              the caption line.
     #                              NOTE: omitting the '0' before the '24' would pad
     #                              or truncate the text so it would be 24% from the
     #                              right.
     #    "%{+b}                  - add ('+') [b]old to the current text effects, but
     #                              don't change the current colors.
     #    " %C:%s%a %D %d %M %Y"  - print the [C]urrent time, a colon, the [s]econds,
     #                              whether it's [a]m or pm, the [D]ay name, the [d]ay
     #                              of the month, the [M]onth, and the [Y]ear.
     #                              (this takes up 24 characters, so the previous
     #                              pad/truncate command makes sure the clock doesn't
     #                              get pushed off of the caption line)
     #    "%{= dd}"               - revert to the [d]efault background and [d]efault
     #                              foreground colors, respectively, with no ('= ')
     #                              other effects.
     #  other things that might be useful later are
     #    " %H"                   - print a space, then the [H]ostname.
     #    "(%{.K}%l%{-}):"        - print a '(', then change the text color to grey
     #                              (aka bright blac[K]), and print the current system
     #                              [l]oad.  Then revert to the previous colorscheme
     #                              ('%{-}') and print a close ')' and a colon.
     #                              NOTE: the load is only updated when some other
     #                              portion of the caption string needs to be changed
     #                              (like the seconds in the clock, or if there were a
     #                              backtick command)
     #    "%0`"                   - put the output of a backtick command in the line
     #    "%-024<"                - don't pad, just truncate if the string is past 24
     #                              characters from the right edge
     #    "%-="                   - pad (with spaces) the previous text text so that
     #                              the rest of the caption string is justified
     #                              against the right edge of the screen.
     #                              NOTE: doesn't appear to truncate previous text.
     caption always           "%?%F%{= Kk}%:%{=u kR}%?  %h %-024=%{+b} %C%a %D %d %M %Y%{= db}"
     # use the hardstatus line for the window list
     #    alwayslastline      - always display the hardstatus as the last line of the
     #                          terminal
     #    "%{= kR} %-Lw"      - change to a blac[k] background with bright [R]ed text,
     #                          and print all the tab [w]indow numbers and titles in
     #                          the [L]ong format (ie with flags) upto ('-') the
     #                          current tab window
     #    "%{=b Kk} %n%f %t " - change to grey (bright blac[K]) background with
     #                          [b]old blac[k] text, with no other effects, and print
     #                          the [n]umber of the current tab window, any [f]lags it
     #                          might have, and the [t]itle of the current tab window
     #                          (as set by zsh - see zshrc).
     #                          NOTE: the color match with the caption line makes it
     #                          appear as if a 'tab' is dropping down from the caption
     #                          line, highlighting the number & title of the current
     #                          tab window.  Nifty, ain't it)
     #    "%{-}%+Lw "         - revert to the previous color scheme (red on black)
     #                          and print all the tab [w]indow numbers and titles in
     #                          the [L]ong format (ie with flags) after ('+') the
     #                          current tab window.
     #    "%=%{= dd}"         - pad all the way to the right (since there is no text
     #                          that follows this) and revert to the [d]efault
     #                          background and [d]efault foreground colors, with no
     #                          ('= ') other effects.
     hardstatus alwayslastline "%{= kR} %-Lw%{=b Kk} %n%f %t %{-}%+Lw %=%{= dd}"
    

    所以这是我的 zshrc 设置,用于告诉屏幕我在每个选项卡中所做的事情。

    # ~/.zshrc
    # if using GNU screen, let the zsh tell screen what the title and hardstatus
    # of the tab window should be.
    if [[ $TERM == "screen" ]]; then
      _GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^~$USER/~/"'
    
      # use the current user as the prefix of the current tab title (since that's
      # fairly important, and I change it fairly often)
      TAB_TITLE_PREFIX='"`'$_GET_PATH' | sed "s:..*/::"`$PROMPT_CHAR"'
      # when at the shell prompt, show a truncated version of the current path (with
      # standard ~ replacement) as the rest of the title.
      TAB_TITLE_PROMPT='$SHELL:t'
      # when running a command, show the title of the command as the rest of the
      # title (truncate to drop the path to the command)
      TAB_TITLE_EXEC='$cmd[1]:t'
    
      # use the current path (with standard ~ replacement) in square brackets as the
      # prefix of the tab window hardstatus.
      TAB_HARDSTATUS_PREFIX='"[`'$_GET_PATH'`] "'
      # when at the shell prompt, use the shell name (truncated to remove the path to
      # the shell) as the rest of the title
      TAB_HARDSTATUS_PROMPT='$SHELL:t'
      # when running a command, show the command name and arguments as the rest of
      # the title
      TAB_HARDSTATUS_EXEC='$cmd'
    
      # tell GNU screen what the tab window title ($1) and the hardstatus($2) should be
      function screen_set()
      {
        # set the tab window title (%t) for screen
        print -nR $'\033k'$1$'\033'\\\
    
        # set hardstatus of tab window (%h) for screen
        print -nR $'\033]0;'$2$'\a'
      }
      # called by zsh before executing a command
      function preexec()
      {
        local -a cmd; cmd=(${(z)1}) # the command string
        eval "tab_title=$TAB_TITLE_PREFIX$TAB_TITLE_EXEC"
        eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX$TAB_HARDSTATUS_EXEC"
        screen_set $tab_title $tab_hardstatus
      }
      # called by zsh before showing the prompt
      function precmd()
      {
        eval "tab_title=$TAB_TITLE_PREFIX$TAB_TITLE_PROMPT"
        eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX$TAB_HARDSTATUS_PROMPT"
        screen_set $tab_title $tab_hardstatus
      }
    fi
    
    • 12
  3. jrockway
    2009-05-04T19:16:28+08:002009-05-04T19:16:28+08:00

    恕我直言,最有用的屏幕自定义是将修饰键更改为 Ca 以外的其他内容。这对一个键来说太重要了,不能吃(在所有 readline 提示和 emacs 中转到行首)。我使用 Cz,因为与在行首编辑某些内容相比,我需要暂停应用程序的次数要少得多。

    神奇的词是:

    escape ^za
    
    • 10
  4. staticsan
    2009-06-09T17:40:16+08:002009-06-09T17:40:16+08:00

    我经常运行 10 多个窗口,并且想要一种方法来选择它们。我发现了如何配置 Ca Shift+0 到 9 来选择 Windows 10 到 19。

    bind  ! select 11
    bind  @ select 12
    bind \# select 13
    bind  $ select 14
    bind  % select 15
    bind \^ select 16
    bind  & select 17
    bind  * select 18
    bind  ( select 19
    bind  ) select 10
    

    注意 # 和 ^ 上的转义。

    • 9
  5. Sean
    2012-08-15T17:08:41+08:002012-08-15T17:08:41+08:00

    是否厌倦了关闭后仍留在回滚缓冲区中的全屏程序(如 vim)?如果它们完全消失,就像您不运行屏幕时那样,那不是很好吗?试着把它放在你的 ~/.screenrc 文件中......

    altscreen on
    
    • 6
  6. tboerman
    2011-10-05T16:03:50+08:002011-10-05T16:03:50+08:00

    我正在使用 Ctrl+Alt+Left 和 Ctrl+Alt+Right 在屏幕窗口之间切换。对于我的 IRSSI 频道,我使用 Alt+Left 和 Alt+Right,而对于 GNOME 工作区切换,我使用 Ctrl+Alt+Shift+Left/Right。看起来很复杂,但实际上效果很好。

    GNOME 终端的字符代码与通过 PuTTy 连接时的字符代码不同,所以我不得不复制条目。您可以使用cat > /dev/null来找出适合您的字符代码。

    #     KEYBOARD SHORTCUTS    #
    # execute 'cat > /dev/null' to see the character codes
    
    # Change Escape Combination to Ctrl+f (Ctrl+a is too useful to lose)
    escape ^Ff
    
    # PREVIOUS WINDOW
    # Ctrl + Alt + Left from gnome-terminal
    bindkey ^[[1;7C prev
    
    # Ctrl+Alt+Left from putty
    bindkey ^[^[[D prev
    
    # NEXT WINDOW
    # Ctrl + Alt + Right from gnome-terminal
    bindkey ^[[1;7D next
    
    # Ctrl+Alt+Right from putty
    bindkey ^[^[[C next
    
    • 2
  7. Bruno Bronosky
    2009-06-11T10:27:59+08:002009-06-11T10:27:59+08:00

    反引号命令非常时髦。在人屏中阅读它。我像这样使用它:

    backtick 1 15 15 $HOME/bin/cpuusage
    # now add '%1`%% CPU' to your hardstatus string. Result is like 38.4% CPU.
    

    我用于 Linux 和 Mac 的 cpuusage 脚本是:

    #!/bin/bash
    if [[ $(uname) == "Darwin" ]]; then
        top -i1 -l2 -n0|awk '/CPU/{i+=1; gsub(/%/,"",$0);p=substr(sprintf("%3.2f",$8+$10),0,4);if(i==2){printf "%g", p}}'
      else
        awk 'NR==1 {p=substr(sprintf("%3.2f", ($2+$3)/($2+$3+$4+$5)*100),0,4); printf "%g", p;}'</proc/stat
    fi
    
    • 1
  8. Mikeage
    2009-05-04T17:38:33+08:002009-05-04T17:38:33+08:00

    没有菜单栏我也活不下去。我不喜欢把很多人都放在菜单上的一件事是时间。它可以防止 PuTTY 的回滚保持回滚状态(因为它被认为是屏幕更新)

    • 0
  9. theotherreceive
    2009-06-21T09:51:37+08:002009-06-21T09:51:37+08:00

    我将 F11 和 F12 设置为在窗口之间循环,可以更快地在窗口之间移动,尤其是对于大于 10 的窗口

    # Bind F11 and F12 (NOT F1 and F2) to previous and next screen window
    bindkey -k F1 prev
    bindkey -k F2 next
    
    • 0
  10. Trey Hunner
    2010-06-03T22:03:20+08:002010-06-03T22:03:20+08:00

    如果您使用的是 urxvt,以下内容将允许CTRL+LEFT并CTRL+RIGHT用于移动到上一个和下一个选项卡窗口:

    bindkey "^[Od" prev  # ctrl-left
    bindkey "^[Oc" next  # ctrl-right
    

    重新连接到应始终运行或立即创建的远程屏幕会话:

    bind V screen -t MYTABNAME ssh -t MYUSERNAME "screen -x main || screen -R -S main"
    

    默认情况下关闭流控制允许您CTRL+R在 rtorrent 中正确使用:

    defflow off
    

    如果使用自己的用户帐户将rtorrent 作为守护程序运行,则此 .screenrc 可能很有用:

    vbell off
    startup_message off
    escape ^Rr
    screen -t rtorrent rtorrent
    multiuser on
    acladd YOURUSERNAME
    defflow off
    
    • 0

相关问题

  • 多操作系统环境的首选电子邮件客户端

  • 你最喜欢的 Linux 发行版是什么?[关闭]

  • 更改 PHP 的默认配置设置?

  • 保护新的 Ubuntu 服务器 [关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve