Is there a Linux command that will list all available commands and aliases for this terminal session?
As if you typed 'a' and pressed tab, but for every letter of the alphabet. Or running 'alias' but also returning commands.
Why? I'd like to run the following and see if a command is available:
ListAllCommands | grep searchstr
You can use the bash(1) built-in
compgen
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.Check the man page for other completions you can generate.
To directly answer your question:
should do what yout want.
Add to .bashrc
If you also want aliases, then:
Try to press ALT-? (alt and question mark at the same time). Give it a second or two to build the list. It should work in bash.
maybe i'm misunderstanding but what if you press Escape until you got the Display All X possibilities ?
There is the
command which lists all aliases and commands in $PATH where mycommand is used. Can be used to check if the command exists in several variants. Other than that... There's probably some script around that parses $PATH and all aliases, but don't know about any such script.
Try this script: