Autocomplete

2 snippets across 2 stacks - Bash & Linux, HTML & CSS

SHBash & Linux

Tab Completion

SH · Shortcuts & Productivity
Syntax
Tab       # complete
Tab Tab   # show all possibilities
Example
cd /etc/ng<Tab>
# Completes to: cd /etc/nginx/

git che<Tab><Tab>
# Shows: checkout  cherry  cherry-pick

Note Tab completion works for commands, file paths, and (with bash-completion or zsh plugins) for subcommands and flags of many tools including git, docker, kubectl, and ssh hosts. Install bash-completion for enhanced support in Bash.

HCHTML & CSS

Datalist (Autocomplete Suggestions)

HC · Forms
Syntax
<input list="list-id">
<datalist id="list-id">
  <option value="suggestion">
</datalist>
Example
<label for="framework">Framework:</label>
<input type="text" id="framework" name="framework" list="frameworks">
<datalist id="frameworks">
  <option value="React">
  <option value="Vue">
  <option value="Angular">
  <option value="Svelte">
  <option value="Solid">
</datalist>

Note Unlike select, datalist allows free-text entry in addition to the suggestions. The user is not forced to pick from the list. Browser rendering of suggestions varies.

Frequently asked questions

How does Bash & Linux handle autocomplete?
This task is covered in 2 stacks on this page: Bash & Linux, HTML & CSS. The "Tab Completion" snippet in Bash & Linux uses `Tab # complete`.
Which command does the Bash & Linux example use?
The "Tab Completion" snippet uses `Tab # complete`, from the Shortcuts & Productivity section of the Bash & Linux cheat sheet.
Which stacks cover "autocomplete" on this page?
Bash & Linux, HTML & CSS. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Tab Completion": Tab completion works for commands, file paths, and (with bash-completion or zsh plugins) for subcommands and flags of many tools including git, docker, kubectl, and ssh hosts. Install bash-completion for enhanced support in Bash.