1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-08-23 01:04:03 +02:00
tldr/pages/common/compgen.md

39 lines
851 B
Markdown
Raw Normal View History

2018-03-31 17:51:22 +08:00
# compgen
> Bash built-in command for generating possible completion matches in Bash.
> Usually used within custom completion functions.
> See also: `complete`, `compopt`.
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-compgen>.
2018-03-31 17:51:22 +08:00
- List all shell built-ins, aliases, functions and executables that you could run:
2018-03-31 17:51:22 +08:00
`compgen -c`
- List all commands that you could run that start with a specified string and save results to `COMPREPLY`:
`compgen -V COMPREPLY -c {{str}}`
- Match against a wordlist:
`compgen -W "{{apple orange banana}}" {{a}}`
2018-03-31 17:51:22 +08:00
- List all aliases:
`compgen -a`
- List all functions that you could run:
`compgen -A function`
- Show shell reserved keywords:
2018-03-31 17:51:22 +08:00
`compgen -k`
- See all available commands/aliases starting with 'ls':
`compgen -ac {{ls}}`
- List all users on the system:
`compgen -u`