dotfiles/.config/fish/functions/menu.fish
2026-01-28 00:57:01 +01:00

25 lines
609 B
Fish

function menu --description 'Opens a menu of a list of Strings and writes the result to stdout'
argparse h/help p/prompt=? index -- $argv
or return
if set -ql _flag_help
echo "menu [-h|--help] [-p|--prompt=?] [--placeholder] [--index] [STRING ...]"
return 0
end
set fuzzel_args
if set -ql _flag_prompt
set -a fuzzel_args "--prompt=$_flag_prompt"
end
if set -ql _flag_placeholder
set -a fuzzel_args "--placeholder=$_flag_placeholder"
end
if set -ql _flag_index
set -a fuzzel_args "--index"
end
string join -- \n $argv | fuzzel --dmenu -l (count $argv) $fuzzel_args || exit 0
end