X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=6a6f1e612f9614d95a00e7ccd743d0ad871d4de1;hb=45c3009de8faccc909736af1cbd8b3f29f8dde96;hp=04949798a4e2748dcc453d9fdb795085b3ec453f;hpb=3c6ce0c89572946347f253bea36ec7670a7123c5;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 0494979..6a6f1e6 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1274,7 +1274,6 @@ if check_com -c screen || check_com -c tmux; then compadd -a _screen_display_wordlist } #m# k CTRL-x\,\,\,S Complete word from GNU screen buffer - #k# Complete word from GNU screen buffer bindkey -r "^xS" compdef -k _complete_screen_display complete-word '^xS' fi @@ -1907,6 +1906,14 @@ grml_prompt_token_default=( vcs '0' ) +function grml_theme_has_token () { + if (( ARGC != 1 )); then + printf 'usage: grml_theme_has_token \n' + return 1 + fi + (( ${+grml_prompt_token_default[$1]} )) +} + function GRML_theme_add_token_usage () { cat <<__EOF__ Usage: grml_theme_add_token [-f|-i] [
 ]
@@ -1928,6 +1935,11 @@ function GRML_theme_add_token_usage () {
     return value is expected in the \$REPLY parameter. The use of these
     options is mutually exclusive.
 
+    There is a utility function \`grml_theme_has_token', which you can use
+    to test if a token exists before trying to add it. This can be a guard
+    for situations in which a \`grml_theme_add_token' call may happen more
+    than once.
+
   Example:
 
     To add a new token \`day' that expands to the current weekday in the
@@ -1991,7 +2003,7 @@ grml_theme_add_token: 
 and  need to by specified _both_!\n\n'
         shift 2
     fi
 
-    if (( ${+grml_prompt_token_default[$name]} )); then
+    if grml_theme_has_token $name; then
         printf '
 grml_theme_add_token: Token `%s'\'' exists! Giving up!\n\n' $name
         GRML_theme_add_token_usage
@@ -2036,7 +2048,7 @@ function grml_prompt_addto () {
     for it in "${items[@]}"; do
         zstyle -s ":prompt:${grmltheme}:${lr}:items:$it" pre apre \
             || apre=${grml_prompt_pre_default[$it]}
-        zstyle -s ":prompt:grml:${grmltheme}:${lr}:$it" post apost \
+        zstyle -s ":prompt:${grmltheme}:${lr}:items:$it" post apost \
             || apost=${grml_prompt_post_default[$it]}
         zstyle -s ":prompt:${grmltheme}:${lr}:items:$it" token new \
             || new=${grml_prompt_token_default[$it]}