From a8a545c7dd1debae309aa10f8de304a505eca39a Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Mon, 24 Feb 2020 10:56:12 +0100 Subject: [PATCH] Ditch shrink_path plugin, shrink path manually New Option: SHELLDER_KEEP_PATH You can turn off shrinking via exporing SHELLDER_KEEP_PATH variable --- README.md | 13 +++++++++++++ shellder.zsh-theme | 22 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0274235..c1f34f4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/shellder.zsh-theme b/shellder.zsh-theme index 8b02319..89ba043 100644 --- a/shellder.zsh-theme +++ b/shellder.zsh-theme @@ -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) '