Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

the function to show a digit argument while it is being typed



hi

in bash a digit argument is showed when it is being typed

i have writed small function which do the same

#####
function digit-argument-show-while-entering {
	arg="${KEYS[2]}"
	if [[ $arg == - ]]
	then
		zle .neg-argument
	else
		zle .digit-argument
	fi
	while true
	do
		PREDISPLAY="(arg: $arg) "
		zle -R

		read -k k1
		if [[ $k1 == $'\C-g' ]]
		then
			NUMERIC=1
			break
		elif [[ $k1 != $'\e' ]]
		then
			zle -U $k1
			break
		fi

		read -k k2
		if [[ $k2 == <0-9> ]]
		then
			arg=$arg$k2
			NUMERIC=$arg
		else
			zle -U "$k1$k2"
			break
		fi
	done
	PREDISPLAY=""
}
zle -N digit-argument digit-argument-show-while-entering
zle -N neg-argument digit-argument-show-while-entering
#####

it is not well tested but seems to be working

-- 
with best regards
Dmitry Bolshakov



Messages sorted by: Reverse Date, Date, Thread, Author