From a7f5170d68c0b75a9864763a90ac11e51ec67c81 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 31 Aug 2020 17:38:30 +0200 Subject: Remove perl dependency --- themes/fishy.zsh-theme | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'themes/fishy.zsh-theme') diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme index 00a60f45b..f6dae6181 100644 --- a/themes/fishy.zsh-theme +++ b/themes/fishy.zsh-theme @@ -1,12 +1,15 @@ # ZSH Theme emulating the Fish shell's default prompt. _fishy_collapsed_wd() { - echo $(pwd | perl -pe ' - BEGIN { - binmode STDIN, ":encoding(UTF-8)"; - binmode STDOUT, ":encoding(UTF-8)"; - }; s|^$ENV{HOME}|~|g; s|/([^/.])[^/]*(?=/)|/$1|g; s|/\.([^/])[^/]*(?=/)|/.$1|g -') + local -a pwd=("${(s:/:)PWD/#$HOME/~}") + for i in {1..$(($#pwd-1))}; do + if [[ "$pwd[$i]" = .* ]]; then + pwd[$i]="${${pwd[$i]}[1,2]}" + else + pwd[$i]="${${pwd[$i]}[1]}" + fi + done + echo "${(j:/:)pwd}" } local user_color='green'; [ $UID -eq 0 ] && user_color='red' -- cgit v1.2.3-70-g09d2 From 7256c03ce1c54bd08ecab954c91a0231386556a6 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 2 Sep 2020 15:15:24 +0200 Subject: fishy: fix one-level directory bug and bad array assignment in zsh 5.0.1 --- themes/fishy.zsh-theme | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'themes/fishy.zsh-theme') diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme index f6dae6181..2b8d559e5 100644 --- a/themes/fishy.zsh-theme +++ b/themes/fishy.zsh-theme @@ -1,14 +1,17 @@ # ZSH Theme emulating the Fish shell's default prompt. _fishy_collapsed_wd() { - local -a pwd=("${(s:/:)PWD/#$HOME/~}") - for i in {1..$(($#pwd-1))}; do - if [[ "$pwd[$i]" = .* ]]; then - pwd[$i]="${${pwd[$i]}[1,2]}" - else - pwd[$i]="${${pwd[$i]}[1]}" - fi - done + local i pwd + pwd=("${(s:/:)PWD/#$HOME/~}") + if (( $#pwd > 1 )); then + for i in {1..$(($#pwd-1))}; do + if [[ "$pwd[$i]" = .* ]]; then + pwd[$i]="${${pwd[$i]}[1,2]}" + else + pwd[$i]="${${pwd[$i]}[1]}" + fi + done + fi echo "${(j:/:)pwd}" } -- cgit v1.2.3-70-g09d2