about summary refs log tree commit diff
path: root/Functions/Prompts/prompt_adam1_setup
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-10-04 22:57:19 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-10-04 22:57:19 +0000
commitd3170c8ee6eb6aa6050d6531536e5e9fba278b57 (patch)
tree4be666df9d3dcce75a68560c44f40b6efe79c24d /Functions/Prompts/prompt_adam1_setup
parent298c35419d8da664ba22f9daa26758798da390d4 (diff)
downloadzsh-d3170c8ee6eb6aa6050d6531536e5e9fba278b57.tar.gz
zsh-d3170c8ee6eb6aa6050d6531536e5e9fba278b57.tar.xz
zsh-d3170c8ee6eb6aa6050d6531536e5e9fba278b57.zip
Initial revision
Diffstat (limited to 'Functions/Prompts/prompt_adam1_setup')
-rw-r--r--Functions/Prompts/prompt_adam1_setup33
1 files changed, 33 insertions, 0 deletions
diff --git a/Functions/Prompts/prompt_adam1_setup b/Functions/Prompts/prompt_adam1_setup
new file mode 100644
index 000000000..65d1b68c0
--- /dev/null
+++ b/Functions/Prompts/prompt_adam1_setup
@@ -0,0 +1,33 @@
+# adam1 prompt theme
+
+prompt_adam1_setup () {
+  base_prompt="%{$bg_no_bold_blue%}%n@%m%{$reset_color%} "
+  post_prompt="%{$reset_color%}"
+
+  base_prompt_no_color=$(echo "$base_prompt" | perl -pe "s/%{.*?%}//g")
+  post_prompt_no_color=$(echo "$post_prompt" | perl -pe "s/%{.*?%}//g")
+
+  precmd  () { prompt_adam1_precmd }
+  preexec () { }
+}
+
+prompt_adam1_precmd () {
+  setopt noxtrace localoptions
+  local base_prompt_expanded_no_color base_prompt_etc
+  local prompt_length space_left
+
+  base_prompt_expanded_no_color=$(print -P "$base_prompt_no_color")
+  base_prompt_etc=$(print -P "$base_prompt%(4~|...|)%3~")
+  prompt_length=${#base_prompt_etc}
+  if [[ $prompt_length -lt 40 ]]; then
+    path_prompt="%{$fg_bold_cyan%}%(4~|...|)%3~%{$fg_bold_white%}"
+  else
+    space_left=$(( $COLUMNS - $#base_prompt_expanded_no_color - 2 ))
+    path_prompt="%{$fg_bold_green%}%${space_left}<...<%~$prompt_newline%{$fg_bold_white%}"
+  fi
+  PS1="$base_prompt$path_prompt %# $post_prompt"
+  PS2="$base_prompt$path_prompt %_> $post_prompt"
+  PS3="$base_prompt$path_prompt ?# $post_prompt"
+}
+
+prompt_adam1_setup "$@"