Add support for three display modes of the path in the prompt: short, medium and long

This commit is contained in:
Andreas Galauner
2015-08-27 20:06:06 +02:00
parent f5d28adfd9
commit 5941592060
2 changed files with 14 additions and 3 deletions

View File

@@ -170,7 +170,7 @@ or don't want to see. All options must be overridden in your **.zshrc** file.
|`BULLETTRAIN_DIR_BG`|`blue`|Background color |`BULLETTRAIN_DIR_BG`|`blue`|Background color
|`BULLETTRAIN_DIR_FG`|`white`|Foreground color |`BULLETTRAIN_DIR_FG`|`white`|Foreground color
|`BULLETTRAIN_DIR_CONTEXT_SHOW`|`false`|Show user and machine in an SCP formatted style |`BULLETTRAIN_DIR_CONTEXT_SHOW`|`false`|Show user and machine in an SCP formatted style
|`BULLETTRAIN_DIR_EXTENDED`|`true`|Extended path |`BULLETTRAIN_DIR_EXTENDED`|`1`|Extended path (0=short path, 1=medium path, 2=complete path, everything else=medium path)
### Git ### Git

View File

@@ -107,7 +107,7 @@ if [ ! -n "${BULLETTRAIN_DIR_CONTEXT_SHOW+1}" ]; then
BULLETTRAIN_DIR_CONTEXT_SHOW=false BULLETTRAIN_DIR_CONTEXT_SHOW=false
fi fi
if [ ! -n "${BULLETTRAIN_DIR_EXTENDED+1}" ]; then if [ ! -n "${BULLETTRAIN_DIR_EXTENDED+1}" ]; then
BULLETTRAIN_DIR_EXTENDED=true BULLETTRAIN_DIR_EXTENDED=1
fi fi
# GIT # GIT
@@ -319,7 +319,18 @@ prompt_dir() {
local dir='' local dir=''
local _context="$(context)" local _context="$(context)"
[[ $BULLETTRAIN_DIR_CONTEXT_SHOW == true && -n "$_context" ]] && dir="${dir}${_context}:" [[ $BULLETTRAIN_DIR_CONTEXT_SHOW == true && -n "$_context" ]] && dir="${dir}${_context}:"
[[ $BULLETTRAIN_DIR_EXTENDED == true ]] && dir="${dir}%4(c:...:)%3c" || dir="${dir}%1~"
if [[ $BULLETTRAIN_DIR_EXTENDED == 0 ]]; then
#short directories
dir="${dir}%1~"
elif [[ $BULLETTRAIN_DIR_EXTENDED == 2 ]]; then
#long directories
dir="${dir}%0~"
else
#medium directories (default case)
dir="${dir}%4(c:...:)%3c"
fi
prompt_segment $BULLETTRAIN_DIR_BG $BULLETTRAIN_DIR_FG $dir prompt_segment $BULLETTRAIN_DIR_BG $BULLETTRAIN_DIR_FG $dir
} }