Ditch shrink_path plugin, shrink path manually

New Option: SHELLDER_KEEP_PATH

You can turn off shrinking via exporing SHELLDER_KEEP_PATH variable
master
Bo Maryniuk 2020-02-24 10:56:12 +01:00 committed by Daiko
parent 00f57f20ff
commit a8a545c7dd
2 changed files with 31 additions and 4 deletions

View File

@ -33,6 +33,19 @@ github:
- simnalamburt/shellder
```
 
Configuration
-------
You can turn off Fish-like path shrinking by adding the following to your `~/.zshrc`:
```zsh
# ~/.zshrc
export SHELLDER_KEEP_PATH=1
```
 
## Fonts
You'll need a powerline patched font. If you don't have one, download one or
patch some fonts on you own.

View File

@ -201,13 +201,28 @@ prompt_hg() {
fi
}
# Turn '/some/quite/very/long/path' into '/s/q/v/l/path'
function shrinked_path() {
local paths=(${PWD/$HOME/\~}) 'cur_dir'
paths=(${(s:/:)paths})
for idx in {1..$#paths}; do
if [[ idx -lt $#paths ]]; then
cur_dir+="${paths[idx]:0:1}"
else
cur_dir+="${paths[idx]}"
fi
cur_dir+='/'
done
echo "${cur_dir: :-1}"
}
# Dir: current working directory
prompt_dir() {
local dir
if (( $+functions[shrink_path] )); then
dir=$(shrink_path -f)
else
if [[ -n $SHELLDER_KEEP_PATH ]]; then
dir='%~'
else
dir=$(shrinked_path)
fi
prompt_segment "$SHELLDER_DIRECTORY_BG" "$SHELLDER_DIRECTORY_FG" "$dir"
}
@ -247,5 +262,4 @@ build_prompt() {
}
export VIRTUAL_ENV_DISABLE_PROMPT='true'
setopt prompt_subst
PROMPT='%{%f%b%k%}$(build_prompt) '