Экранируйте строку состояния для отображения текущего каталога для оболочки zsh/bash

Если нет никого другого screen сессии, выполняющие Вас, могут использовать "твердый" путь и просто kill их с killall screen.

Если Вы хотите быть хорошими, можно выполнить итерации по списку экранных сессий и уничтожить их один за другим:

# screen -S foo && screen -S foo
[detached]
[detached]
# screen -ls
There are screens on:                                                                                                                                                                                      
        8350.foo        (Detached)                                                                                                                                                                         
        8292.foo        (Detached)                                                                                                                                                                         
2 Sockets in /tmp/screens/S-joschi.                                                                                                                                                                        

# This is the interesting line. Just replace "foo" with the name of your session(s)
# for session in $(screen -ls | grep -o '[0-9]*\.foo'); do screen -S "${session}" -X quit; done
# screen -ls
No Sockets found in /tmp/screens/S-joschi.
10
06.01.2012, 13:38
2 ответа

Для zsh:

Вставьте это Ваш ~/.zsh

[centos@centos ~]$ cat .zsh
if [[ ${TERM} == "screen-bce" || ${TERM} == "screen" ]]; then
  precmd () { print -Pn "\033k\033\134\033k%m[%1d]\033\134" }
  preexec () { print -Pn "\033k\033\134\033k%m[$1]\033\134" }
else
  precmd () { print -Pn "\e]0;%n@%m: %~\a" }
  preexec () { print -Pn "\e]0;%n@%m: $1\a" }
fi
PS1=$'%{\e[0;32m%}%m%{\e[0m%}:%~> '
export PS1
[centos@centos ~]$ 

В Вашем ~/.screenrc

hardstatus string "%h"
caption always "%{= kw} %-w%{= wk}%n*%t%{-}%+w%{= kw} %=%d %M %0c %{g}%H%{-}"
4
27.01.2020, 20:02

Вставьте это Ваш ~/.screenrc

caption always "%m/%d/%y %0c%{=b kg}  %l  %{=r gk}%-w%{=b wb}%50>%n%f* %t%{-}%+Lw%<%{- Wk}"

caption always "%m/%d/%y %0c%{=b kg}  %l  %{=r gk}%-w%{=b wb}%50>%n%f* %t%{-}%+Lw%<%{- Wk}"

# caption description:
# caption always "%?%F%{-b bc}%:%{-b bb}%?%C|%D|%M %d|%H%?%F%{+u wb}%? %L=%-Lw%45>%{+b by}%n%f* %t%{-}%+Lw%-0<"
# 
# Anything I don't describe is treated literally.
# 
# %?          - Start of a conditional statement.
#  %F         - Use this part of the statement if the window has focus (i.e. it
#               is the only window or the currently active one).
#  %{-b bc}   - Turn off bold, blue foreground, cyan background.
# %:          - else
#  %{-b bb}   - Turn off bold, blue foreground, blue background (this obscures
#               the text on non-focused windows and just gives a blue line).
# %?          - End conditional statement.
#  %C         - time (hh:mm, leading space) in 12 hour format
#  %D         - Three-letter day-of-week appreviation
#  %M         - Three-letter month appreviation
#  %d         - Day of the month
#  %H         - hostname
#  %?         - Start of conditional statement.
#   %F        - Use this part of the statement if the window has focus.
#   %{+u wb}  - underlined, white foreground, blue background
#  %?         - End conditional (if not focused, text remaind blue on blue).
#    %L=      - truncation/padding point.  With the 'L' qualifier, basically
#               just acts as a reference point.  Further truncation/padding is
#               done relative to here, not the beginning of the string
#    %-Lw     - window list up to but not including the current window (-),
#               show window flags (L)
#    %45>     - truncation/padding marker; place this point about 45% of the

#               way into the display area (45)
#    %{+b by} - add bold (still underlined from before), blue foreground,
#               yellow background
#      %n     - number of the current window
#      %f     - flags for current window
#      %t     - title of current window
#    %{-}     - undo last color change (so now we're back to underlined white
#               on blue)  (technically, this is a pop; a second invocation
#               would drop things back to unadorned blue on cyan)
#    %+Lw     - window list from the next window on (-), show window flags (L)
#    %-0<     - truncation/padding point.  Place this point zero spaces (0)
#               from the right margin (-).

Или можно просто поместить это как заголовок оболочки, если Вам просто нужен заголовок окна, которое будет отображено как текущий рабочий каталог.

Это входит в Ваш ~/.bashrc:

PROMPT_COMMAND='echo -ne "\033k\033\0134\033k${HOSTNAME}[`basename ${PWD}`]\033\0134"'`

Это входит в Ваш ~/.screenrc: shelltitle '] | bash'

8
27.01.2020, 20:02
  • 1
    ... И с zsh? ^ _ ~ –  Sardathrion - Reinstate Monica 06.01.2012, 12:56
  • 2
    0 перед 134 работы для меня в ударе; PROMPT_COMMAND='echo -ne "\033k\033\0134\033k${HOSTNAME}[`basename ${PWD}`]\$\033\0134"' –  mpapec 12.05.2015, 13:25

Теги

Похожие вопросы