#!/usr/bin/env bash
# https://gist.github.com/nicedreams/f8d0a6373949f6d9b9583e7e1634a1c3

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-window="down:wrap:3")
  if [[ "${launchapp}" ]]; then
    setsid -f "${launchapp}" &> /dev/null &
    sleep .1
  fi
}

bmenu "$@"
