mu-wizard

shell script to easily configure mu4e accounts on Emacs
git clone git://git.ckyln.com/mu-wizard
Log | Files | Refs | LICENSE

commit 0cc472c4de2a0ec3601f2f5007f721c74c675a40
parent 907db008dca6b7d06795820fd78ee80fb52d41f3
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 28 Oct 2020 00:35:39 +0300

yesno(): only require a single button press

Diffstat:
Mbin/muw | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/muw b/bin/muw @@ -5,10 +5,18 @@ err() { printf 'err: %s\n' "$@" >&2 ;} die() { err "$@"; exit 1 ;} prompt() { printf '%s\n' "$1"; [ "$2" ] && printf '%s: ' "$2" ;} +getbut() { + stty=$(stty -g) + stty -icanon -echo + dd bs=1 count=1 2>/dev/null + stty "$stty" +} + yesno() { - printf '%s\n' "$@"; printf '[y]es/[n]o: ' - read -r ans - case "$ans" in [Yy]*) return 0; esac; return 1 + printf '%s\n' "$@"; printf 'y/n: ' + ans=$(getbut) + printf '%s\n' "$ans" >&2 + case "$ans" in [Yy]) return 0; esac; return 1 } delete() {