Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Last active December 27, 2015 18:59
Show Gist options
  • Select an option

  • Save michaelminter/7373776 to your computer and use it in GitHub Desktop.

Select an option

Save michaelminter/7373776 to your computer and use it in GitHub Desktop.
List all commands on the command line linux, mac, bash, shell

Add to .bashrc

function ListAllCommands
{
    echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 \
        -executable -type f -printf '%P\n' | sort -u
}

If you also want aliases, then:

function ListAllCommands
{
    COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 \
        -executable -type f -printf '%P\n'`
    ALIASES=`alias | cut -d '=' -f 1`
    echo "$COMMANDS"$'\n'"$ALIASES" | sort -u
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment