How to make Bash <kbd>tab</kbd> not list hidden files and folders starting with `.`?
Jul 23, 11:47am
In Bash, the default behavior of the <kbd>tab</kbd> key (command-line completion) is to list all files and folders, including hidden ones (those starting with a .). To exclude hidden files and folders from tab completion, you can modify the behavior of the readline library, which Bash uses for input handling.
Solution
Add the following line to your ~/.bashrc or ~/.bash_profile file to exclude hidden files and folders from tab completion:
bash
export FIGNORE=".??*"
Explanation:
FIGNORE is a shell variable that specifies suffixes to ignore during filename completion.
The pattern .??* matches all hidden files and folders (those starting with a . and followed by at least one more character).
Steps:
Open your ~/.bashrc or ~/.bash_profile file in a text editor:
bash
nano ~/.bashrc
or
bash
nano ~/.bash_profile
Add the line export FIGNORE=".??*" to the file.
Save the file and exit the editor.
Reload your Bash configuration to apply the changes:
bash
source ~/.bashrc
or
bash
source ~/.bash_profile
Now, when you press <kbd>tab</kbd>, hidden files and folders will not appear in the completion list.
Jul 23, 11:47am
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.