Skip to content

Instantly share code, notes, and snippets.

@nicedreams
Last active October 2, 2023 23:46
Show Gist options
  • Save nicedreams/f8d0a6373949f6d9b9583e7e1634a1c3 to your computer and use it in GitHub Desktop.
Save nicedreams/f8d0a6373949f6d9b9583e7e1634a1c3 to your computer and use it in GitHub Desktop.
bmenu - Shell application launcher using fzf
#!/bin/bash
# bmenu - Shell application launcher using fzf.
# Searches $PATH for executable files and runs selected program.
# Fzf preview window shows info about file.
# Requires: fzf
# Usage: As script like ~/bin/bmenu or copy/paste bmenu() function in ~/.bashrc
bmenu() {
launchapp=$(IFS=':'; \
for p in ${PATH}; \
do find -L "${p}" -type f -executable -print 2> /dev/null; done \
| fzf --header="Select application to launch from PATH:" \
--multi=0 \
--exact \
--height="50%" \
--preview="(file -b {})" \
--preview-window="down:wrap:3")
if [[ "${launchapp}" ]]; then
nohup bash -c "${launchapp}" >/dev/null &
fi
}
bmenu "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment