#!/bin/sh

##?    compgen -c will list all the commands you could run.
##?    compgen -a will list all the aliases you could run.
##?    compgen -b will list all the built-ins you could run.
##?    compgen -k will list all the keywords you could run.
##?    compgen -A function will list all the functions you could run.
##?    compgen -A function -abck will list all the above in one go.

search_commands() {
  # shellcheck disable=SC3044
  selected=$(compgen -c | FZF_DEFAULT_OPTS="-m --ansi --preview=\"command -V {}\"" fzf)
  if [ -n "${selected}" ]; then
    # shellcheck disable=SC2312
    echo "${selected} $(command -V "${selected}")"
  fi
  return "${ret:-1}"
}