• We had to restore from a backup today after a failed software update. Backup was from 0000 EDT and restored it at 0800 EDT so we lost about 8hrs. Today is 07/20/2024. More info here.

Today's article is one I figure most of us here already know...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
12,057
Reaction score
10,689
Credits
99,543
Today I cover tab autocomplete. It's covered all over the web but I know I have readers who will not know about it, or know little about it. It was written while I was bordering on sleep as I actually got distracted and forgot to write an article until like 02:00. I even got an AI involved in the mix, though I almost cut that part out.


It is what it is...
 


On some distribution you will need to install bash-completion since it will not always be installed by default and with zsh you can add plugins to extend the funciontality of auto-completion.
 
On some distribution you will need to install bash-completion since it will not always be installed by default

That's a worthwhile comment to add. Though, I haven't come across a distro like that (that I have noticed) in a long, long time.

Alas, I don't really cover ZSH stuff. While I've played with alternative shells, I'm just not fluent in them enough to write about them comfortably. That might make a good project for me. I could learn more about the other shells. It seems easy enough to do and one of those things that would be trivial to virtualize.
 
That's a worthwhile comment to add. Though, I haven't come across a distro like that (that I have noticed) in a long, long time.
Maybe it's just me then. Could be that I might be confused with the minimal install of distributions like Debian and RHEL and not desktop distributions.
 
Could be that I might be confused with the minimal install of distributions like Debian and RHEL and not desktop distributions.

That might be it. I haven't done a minimal install in ages. I've got ample space. I install all sorts of stuff that I may only use once and never uninstall it. As I tend to move from one device to another by moving an existing install, I can have stuff installed that I literally haven't used in years.

I do not worry about disk space, more or less. Usually, if I'm downloading a large file, I'll download it to a storage device. It's a bit of a kludge, but I tend to use wget to grab large files directly to a NAS of my own making. (Basically a server with a ton of disk space.) Long gone are the days when I worried about data storage. I might go clean up some space every few years.
 
The tab behavior described in the hint when multiple files match the partial text does not match any of the Linux and Mac terminals I tested, other than zsh on macOS 12.6.5 Monterey.

Using the "cd" command as an example, the article implies that if you enter partial text that matches multiple filenames and press the TAB key, the terminal will display the partial matching files and a new partially completed prompt, ready for user input. That is true for macOS 12.6.5 Monterey with the default zsh. It is not true for an older macOS 10.12.6 or any of the Linux distros I tested - desktop and server. Those other systems all default to bash.

What I found on most platforms was that the TAB key is ignored on the first press if there are multiple filename matches. The list of matching filenames is not displayed unless you press the TAB key twice.

Tested in Terminal windows with zsh and bash on Mac (10.12.6 and 12.6.5). Also tested on several different Linux desktops: Mint Cinnamon, MX Linux, Manjaro, Kali, Ubuntu; and Linux Servers: Debian 10 and 11, Ubuntu 22.04, Oracle Linux 8 and 9. Other than zsh on the latest Mac, they all behaved the same and did not match the example in the hint.
 
The list of matching filenames is not displayed unless you press the TAB key twice.

You should find some that work the first time - in my experience most do. I should probably have added that you may need to press it twice in some instances, but it's an outlier in my experience.

I'll find a creative way to add that, thanks. I've gotta edit an article anyhow, so I might as well do this one too. That's definitely worth mentioning as some will make you press it twice. (I have no idea why.)
 
You should find some that work the first time - in my experience most do. I should probably have added that you may need to press it twice in some instances, but it's an outlier in my experience.

I'll find a creative way to add that, thanks. I've gotta edit an article anyhow, so I might as well do this one too. That's definitely worth mentioning as some will make you press it twice. (I have no idea why.)
Sure.

Other than Mac 12 (Monterey) with its default zsh, every single platform defaulted to pressing the TAB key twice. They all had their default bash shells. I am surprised that you are not seeing it the same way. Have you tried any recent popular distros like Mint Cinnamon or plain Ubuntu with regular out-of-the-box installations and their default bash shells?
 
am surprised that you are not seeing it the same way.

It could be that I've tinkered very heavily with my bash and I "cheat" and carry all my dot files from installation to installation, now that I think of it. I could EASILY have mucked about in that area and just carried that behavior forward for years, as I've consistently kept my dot files.
 
And the article is updated. I just crammed it into parentheses. It'll do.

I strongly, strongly suspect it's that I've mucked about with things. Realistically, I should probably clean my dot files up or start again. I just recently removed a half dozen commands from my .bashrc that'd execute every time the terminal was opened.
 


Top