first complete version

This commit is contained in:
2026-03-17 11:01:45 +01:00
parent 28aca1a82b
commit af8c7efae9
12 changed files with 334 additions and 77 deletions

View File

@@ -4,7 +4,6 @@
# @argument $1: Question
# @argument $2: Content to show in preview window
# @return: 0 if the user answered "yes" and 1 otherwise.
#!/bin/sh
ynprompt() {
return $(printf '0 \033[32myes\033[0m\n1 \033[31mno\033[0m\n' |
$FZF \
@@ -17,8 +16,44 @@ ynprompt() {
--preview-window='60%,border-line' \
--margin='5%,5%,5%,15%' \
--preview="echo \"$2\"" \
--with-nth=2 \
--with-nth=2.. \
--accept-nth=1 \
--header-border='line' \
--color='border:yellow,header:yellow')
}
# This prompts the user for a series of options.
# The options are read from stdin in the form "integer\toption\n".
# Prints number
#
# @argument $1: Question
# @argument $2: Content to show in preview window
multiprompt() {
cat |
$FZF \
--reverse \
--no-input \
--header="$1" \
--preview-window='60%,border-line,wrap-word' \
--margin='5%,5%,5%,15%' \
--preview="echo \"$2\"" \
--with-nth=2.. \
--accept-nth=1 \
--header-border='line' \
--bind="ctrl-c,esc,ctrl-q:" \
--color='border:yellow,header:yellow' | head -1 || true
}
# ASCII-encode address
# asciiaddress() {
# firstword=1
# for word in $*; do
# [ "${firstword:-}" ] || echo -n ' ' && firstword=
# case $word in
# *[![:cntrl:][:print:]]*) echo -n $word ;;
# *) return 0 ;;
# esac
# isascii "$word" && echo -n "$word" || echo -n "=?UTF-8?B?$(echo -n "$word" | base64)?="
# done
# }