Skip to content

Instantly share code, notes, and snippets.

@skratchdot
Created December 21, 2018 17:23
Show Gist options
  • Save skratchdot/7df9dbb10e372f78336b0e1358f80fd3 to your computer and use it in GitHub Desktop.
Save skratchdot/7df9dbb10e372f78336b0e1358f80fd3 to your computer and use it in GitHub Desktop.
list-all-commands.sh
#!/usr/bin/env bash
# found these useful commands here:
# https://unix.stackexchange.com/questions/60776/list-all-files-binaries-in-current-path/60808#60808
#
# 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.
# list everything:
compgen -A function -abck | sort | uniq
@skratchdot
Copy link
Author

Put this file in your $PATH (I put it in ~/bin/), then add the following to ~/.bash_aliases:

alias list-all-commands.sh='. ~/bin/list-all-commands.sh'

This is needed based on https://unix.stackexchange.com/questions/102838/run-script-in-current-shell-without-before-command/102860#102860

I was seeing different results when running:
list-all-commands | wc vs . list-all-commands | wc

After adding the alias, they are the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment