DEV Community

William Lake
William Lake

Posted on • Updated on

Create a linux alias to list all available commands

Infomercial-style qualifier: These instructions were created on Ubuntu 18.04. Your mileage may vary.

I find myself constantly Googling Linux commands and then promptly forgetting them. This morning I decided to find a better way, and after creating my own process I thought I'd share. Hopefully it's useful to someone in the future.

Bonus: Found something useful along the way: https://www.commandlinefu.com/commands/browse


How To

Create an alias named allcomm and save it in your .bashrc.
echo "alias allcomm=\"compgen -A function -abck\"" >> ~/.bashrc

Reload your .bashrc so the changes will take effect.
source ~/.bashrc

Usage

Searching results:
allcomm search_string_here

E.g.

allcomm zip

zip
zipnote
zipcloak
zipgrep
zipinfo
zipsplit
zipdetails
Enter fullscreen mode Exit fullscreen mode

Searching via grep:
allcomm | grep search_string_here

E.g.

allcomm | grep zip

zip
preunzip
unzip
zipnote
unzipsfx
zipcloak
zipgrep
zipinfo
funzip
prezip-bin
mzip
zipsplit
zipdetails
gpg-zip
prezip
bzip2recover
bunzip2
gunzip
gzip
bzip2
Enter fullscreen mode Exit fullscreen mode

Source: https://stackoverflow.com/a/949006

Top comments (3)

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard

Combine with the too long didn't read tool

tldr.sh/

Because man pages are only useful as a reference, not as tutorials for common use cases

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard

How to do this with zsh?

Collapse
 
moopet profile image
Ben Sinclair

Zsh supports bash completion, if you tell it to:

autoload bashcompinit && bashcompinit

will tell it to load the compatibility "built-ins" which include compgen. It's not 100% compatible, but that should get you started.