summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Misc/zcalc8
1 files changed, 6 insertions, 2 deletions
diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc
index 80a031a8b..503bcb94b 100644
--- a/Functions/Misc/zcalc
+++ b/Functions/Misc/zcalc
@@ -84,11 +84,13 @@
 emulate -L zsh
 setopt extendedglob
 
-local line latest base defbase match mbegin mend
+local line latest base defbase match mbegin mend psvar
 integer num
 
 zmodload -i zsh/mathfunc 2>/dev/null
 
+: ${ZCALCPROMPT="%1v> "}
+
 # Supply some constants.
 float PI E
 (( PI = 4 * atan(1), E = exp(1) ))
@@ -101,7 +103,8 @@ for (( num = 1; num <= $#; num++ )); do
   print "$num> $argv[$num]"
 done
 
-while vared -chp "$num> " line; do
+psvar[1]=$num
+while vared -cehp "${(%)ZCALCPROMPT}" line; do
   [[ -z $line ]] && break
   # special cases
   # Set default base if `[#16]' or `[##16]' etc. on its own.
@@ -134,6 +137,7 @@ while vared -chp "$num> " line; do
     # arrays always store scalars anyway.
     eval "latest=\$(( $base $line ))"
     argv[num++]=$latest
+    psvar[1]=$num
     print -- $latest
   fi
   line=