Skip to content

Instantly share code, notes, and snippets.

@hidsh
Last active December 24, 2024 01:00
Show Gist options
  • Save hidsh/9febae96fdceafba90c455f7f3bc73fa to your computer and use it in GitHub Desktop.
Save hidsh/9febae96fdceafba90c455f7f3bc73fa to your computer and use it in GitHub Desktop.
show command help w/ fzf
h() {
local tmp_file=/tmp/h
local cmd=''
if [ "$#" -eq 0 ]; then
cmd=$(echo $PATH | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -executable 2>/dev/nul
l | xargs -n 1 basename | fzf);
elif [ "$#" -eq 1 ]; then
cmd=$1
else
echo 'Usage: h shows help for which command choosen via fzf'
echo ' h <command> shows help for <command>'
fi
$cmd --help 1>$tmp_file 2>/dev/null
if [ "$?" != 0 ]; then
echo "No help for $cmd"
else
less $tmp_file
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment