3 ms·
"Extended" tab completion seems like one of those things which sounds like a good idea on the surface, but actually involves considerable hidden complexity, and
by userbinator 5y ago
"Extended" tab completion seems like one of those things which sounds like a good idea on the surface, but actually involves considerable hidden complexity, and when something doesn't work right, can instead cause plenty of confusion and lost productivity.
As someone who routinely uses tab completion to look into the contents of directories before entering them to confirm that they are the correct ones, I was very confused when a recent system I had to use briefly (I don't remember if it was zsh) decided to not show files if the command started with 'cd'. It wasted more time trying to be "helpful" because it required an extra 'ls' which I could essentially get for free via tab completion.
- enriquto 5y agoWhy would you want "cd folder/<TAB>" instead of "ls folder" ?
- gmueckl 5y agoIf you are navigating a complex folder structure, it's easy to start typing > cd path/to/ and then realizing that you don't remember whether you need subdirectory1 or subdirectory2 next. With tab completion, you can just continue typing > cd path/to/subdirectory1<tab><tab> to check whether what's in there is what you're looking for. Without tab completion, you need to move to the start of the line, change "cd" to "ls", run that, go back up in the history, change "ls" to "cd" and continue from there. It's much more inconvenient.
- loa_in_ 5y agoThen what you want is the autocd shell option enabled. See info bash
- JNRowe 5y agoYou don't need to choose, fex bash has complete-filename which is bound to M-/ by default¹. You can rely on smart completion for most uses, but should you suddenly desire to complete a filename in an odd place you simply use the direct binding. There are a variety of other completion mechanisms(user, var, etc) with default bindings available too for other out-of-context uses. ¹ zsh users can imitate the same effect with a custom zle function using `completer _files`
- avian 5y agoSmart completion is the first thing I remove or disable on any system I work on. "Complete with a path on <tab>" is simple to understand and reason with and becomes second nature after working a lot in the shell prompt. "Run a complex set of possibly incomplete/broken rules to come up with a string" is the exact opposite. Commonly bumping at "why isn't this command-line completing/is completing with something unexpected" just negates all benefits of <tab> sometimes working for stuff like git branches, long command-line flags, etc.