화면 상태 표시줄에는 zsh/bash 셸의 현재 디렉터리가 표시됩니다.

화면 상태 표시줄에는 zsh/bash 셸의 현재 디렉터리가 표시됩니다.

나는 종종 GNU 화면을 사용하고 zsh를 쉘로 사용합니다. 탭 제목으로 (전체 경로 대신) 현재 디렉터리 이름을 표시할 수 있다면 좋은 기능이 될 것 같습니다. 할 수는 있지만 CTRL+A SHIFT+A수동으로 해야 합니다. 디렉토리를 변경할 때마다 변경하고 싶습니다.

누구든지 이 작업을 수행하는 방법을 알고 있습니까?

편집: 답변에는 bash 솔루션도 포함되어 있습니다.

답변1

이것을 네 안에 넣어라~/.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'

답변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%{-}"

관련 정보