From 0756bd52724da013549578d94646d6d66234fb54 Mon Sep 17 00:00:00 2001 From: Michel Date: Wed, 17 Jan 2024 16:32:04 +0100 Subject: [PATCH] feat(zsh): whiptail helper --- .zshrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.zshrc b/.zshrc index 73733c2..e4293f8 100644 --- a/.zshrc +++ b/.zshrc @@ -277,6 +277,24 @@ zle -N nnn-file-widget bindkey -M vicmd '\en' nnn-file-widget bindkey -M viins '\en' nnn-file-widget +# Whiptail helper +# +menu_choose() { + local res title="$1" text="$2" + shift 2 + + local -a tags + for tag; + { tags+=($tag $tag) } + + # see https://stackoverflow.com/questions/1970180/whiptail-how-to-redirect-output-to-environment-variable + tag=$(whiptail --title $title --menu $text 25 40 15 $tags --notags 3>&1 1>&2 2>&3 3>&-) + res=$? + + echo $tag + return $res +} + ### ### Aliases -- Global & automatic expansion ###