it-swarm.cn

什么是有用的.screenrc设置?

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

## 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 [email protected]:[email protected]

# 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}]'
54
Gareth

对于那些想要以较小的神秘度来设置尼斯屏幕的方式,我可以衷心推荐 byob (以前称为屏幕配置文件)。它在屏幕底部为您提供了一套不错的默认材料-底行包含各种方便的状态信息,而底行的第二行包含屏幕窗口的列表。所有这些都可以通过按F9在Nice easy ncurses菜单中进行配置。

功能键映射到常见操作:

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

请参阅 本文中的教程和屏幕截图

从业力(9.10)开始,Byobu位于ubuntu存储库中。出于讽刺,它被称为屏幕配置文件。在此之前,可以从 此下载页面此ppa 安装。它也被广泛包装为其他最新发行版。

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

22
Hamish Downer

我还使用了相当复杂的标题/ 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
rampion

最有用的屏幕自定义,恕我直言,是将修改键更改为C-a以外的其他键。那太重要了,不能吃掉一个键(在所有readline提示符和emacs中转到该行的开头)。我使用C-z,因为挂起应用程序的频率比行开始时进行的编辑少得多。

神奇的话是:

escape ^za
10
jrockway

我经常运行10个以上的窗口,并希望有一种选择它们的方法。我发现了如何配置C-a Shift + 0至9以选择窗口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
staticsan

关闭后,像vim这样的全屏程序会残留在回滚缓冲区中吗?如果像不运行时一样完全消失,那不是很好吗?屏幕?尝试将其放在您的〜/ .screenrc文件中...

altscreen on
6
Sean

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

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
tboerman

Backtick命令非常普通。在人机屏幕上阅读有关它的信息。我这样使用它:

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
Bruno Bronosky

如果您使用的是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
Trey Hunner

基于 如何强制Gnu屏幕加载bash .profile 的答案,我将添加:

Shell -$Shell

到您的~/.screenrc使screen启动登录Shell。如果您想要~/.bash_profile通过screen使用Shell时执行。

0
Rodrigue
# disable C-a s, which freezes the screen; can be resolved with C-a q
bind s 
0
Chase T.

我也离不开菜单栏。我不喜欢把很多人放在菜单上的一件事是时间。它防止PuTTY的向后滚动保持向后滚动(因为它被认为是屏幕更新)

0
Mikeage

我将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
theotherreceive