15 lines
543 B
Bash
Executable File
15 lines
543 B
Bash
Executable File
#!/bin/sh
|
|
set -euf
|
|
|
|
menu_cmd="${MENU:-fzfmenu} -p 'run > '"
|
|
cmd="$(IFS=':'; find $PATH \( -type f -o -type l \) | awk -F '/' '{print $NF}' | sort | uniq | eval "$menu_cmd")"
|
|
# this menu will act as if you typed the command in a shell, hence eval and -e sh -c
|
|
# this runs in userspace, so no eval security risk should be present
|
|
# that is, no more of a risk than what said user could do with a shell themselves
|
|
|
|
case "$cmd" in
|
|
''|'!') exit 1 ;;
|
|
*'!') exec "${TERMINAL:-urxvt}" -e sh -c 'exec '"${cmd%!}" ;;
|
|
*) exec sh -c "exec $cmd" ;;
|
|
esac
|