본문 바로가기

기타

[리눅스] zsh 프롬프트 전체 경로 대신 현재 디렉터리만 표시하는 방법(agnoster theme)

728x90

zsh 프롬프트 전체 경로 대신 현재 디렉터리만 표시하는 방법

vim .oh-my-zsh/themes/agnoster.zsh-theme

$ vim .oh-my-zsh/themes/agnoster.zsh-theme
...
# Dir: current working directory
prompt_dir() {
  #prompt_segment blue $CURRENT_FG '%~'
  #prompt_segment blue $CURRENT_FG '%2~'
  #prompt_segment blue $CURRENT_FG ' %25<...<%~%<< '
  prompt_segment blue $CURRENT_FG '%c'
}
...

기본

prompt_segment blue $CURRENT_FG '%~'

25자보다 긴 문자는 ...으로 표시

prompt_segment blue $CURRENT_FG ' %25<...<%~%<< '

  • %25<...< will truncate everything that is longer than 25 characters to ...
  • %<< will basically tell zsh that anything after this should not be truncated (limiting the truncation to the path part)

현재 작업 디렉토리만 표시

prompt_segment blue $CURRENT_FG '%c'

 

728x90