Bash auto complete does not work for me.
In terminal:
Type the first letters of a file name; enter Tab, gives not the expected filename.
How to switch on that feature of Bash?
Running F33 here, GNU bash is Version 5.0.17(1)-release (x86_64-redhat-linux-gnu).
Auto-completion using the key works fine. (Everything is default, no extra package or customization)
ls
TabTab
If you want to extend the completion functionality for some additional commands, install
bash-completion
(If I am not wrong, it’s installed by default)
I did file a bug. Because this problem is in F33 as well as in Rawhide. (two different desktops)
Can you clarify what completion this is? I’ve never known bash to complete filenames without a command. So:
ls <filename start><tab>
completes but
<filename><tab>
does not—is it expected to? (Have I not know of this feature for 10 years! )
If this is the bug you’re referring to:
https://bugzilla.redhat.com/show_bug.cgi?id=1897118
pro <tab> # notice the space after pro
works because bash thinks of pro
as a command, cannot find a specialised completion, and so does the general file name completion—two tabs show all files, <some filename start><tab>
will complete the file name.
try to open rpm file. like this rpm filename -U
when I do rpm “first letters of filename” Tab
bash gives nothing
It is that bug. and it is in two desktops, one a fresh install of Rawhide and the other has F33.
This is expected behaviour. For different options of rpm
, there are different completions.
So, instead of rpm <file> -U
, try:
rpm -U <first letters><tab>
That works just fine.
Similarly, if you use a different option, say -q
, you can do:
rpm -q <tab><tab>
and it’ll show all the installed packages that this command can take as an argument.
Additionally, if you do:
rpm <tab>
it’ll add a -
and if you press tab again, it’ll complete with the possible options that the rpm command can take:
rpm -<tab>
-e -E -F -i -q -t -U -V
This is a very fine answer. I will unfile the bug… Thank you
I also recommend using fzf
to further enhance your experience:
It’s in the Fedora repositories:
sudo dnf install fzf
Also has a vim-plugin
For executables, or for filenames that are needed as io following a valid command it should work as long as the portion already entered is unique. If not unique the second tab will give a list of files in the local directory (or executables in the path) that match that beginning.
I have also seen that when using rpm (or dnf) to install an rpm that is in the local directory it is often necessary to start the file name with ./file and it will then auto-complete.
Great, thank you for the lesson.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.