浏览代码

fishy: fix one-level directory bug and bad array assignment in zsh 5.0.1

Marc Cornellà 3 年之前
父节点
当前提交
7256c03ce1
共有 1 个文件被更改,包括 11 次插入8 次删除
  1. 11 8
      themes/fishy.zsh-theme

+ 11 - 8
themes/fishy.zsh-theme

@@ -1,14 +1,17 @@
 # ZSH Theme emulating the Fish shell's default prompt.
 # ZSH Theme emulating the Fish shell's default prompt.
 
 
 _fishy_collapsed_wd() {
 _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}"
   echo "${(j:/:)pwd}"
 }
 }