Replies: 2 comments 3 replies
-
What's numeric arg? |
Beta Was this translation helpful? Give feedback.
3 replies
-
Here's my implementation: .p10k.zsh function prompt_numeric() {
[[ -n $NUMERIC ]] && p10k segment -f $_P10K_COLOR_GREEN_BRIGHT -i $NUMERIC
} .zshrc digit_argument() {
zle .digit-argument
NUMERIC=$NUMERIC${KEYS[-1]}
-z4h-redraw-prompt
}
zle -N digit_argument
for i in {0..9}; do
bindkey "^[$i" digit_argument
done
neg-argument() {
zle .neg-argument
(( NUMERIC = ${NUMERIC:-1} * -1 ))
-z4h-redraw-prompt
}
zle -N neg-argument
numeric-clear-hook() {
if [[ $LASTWIDGET == (digit_argument|neg-argument) ]] then
LASTNUMERIC=1
elif [[ -n $LASTNUMERIC ]] then
unset LASTNUMERIC NUMERIC
-z4h-redraw-prompt
fi
}
add-zle-hook-widget line-pre-redraw numeric-clear-hook |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like the numeric arg to be displayed at prompt right away when used.
Is it possible?
Beta Was this translation helpful? Give feedback.
All reactions