浏览代码

Update fishy theme to collapse working directory in PROMPT.

For non-trailing path components, we show only the first character. So, as in Fish proper, we convert ~/some/really/really/really/long/path/name to ~/s/r/r/r/l/p/name.
Nicholas Hutchinson 11 年之前
父节点
当前提交
2643ac975b
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      themes/fishy.zsh-theme

+ 5 - 1
themes/fishy.zsh-theme

@@ -1,7 +1,11 @@
 # ZSH Theme emulating the Fish shell's default prompt.
 
+_fishy_collapsed_wd() {
+  echo $(pwd | perl -pe "s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g")
+}
+
 local user_color='green'; [ $UID -eq 0 ] && user_color='red'
-PROMPT='%n@%m %{$fg[$user_color]%}%~%{$reset_color%}%(!.#.>) '
+PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) '
 PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
 
 local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}"