shell-novice icon indicating copy to clipboard operation
shell-novice copied to clipboard

Auto completion on commands

Open hmatthes opened this issue 4 years ago • 2 comments

When I am a helper at teaching the shell lesson, one common learner's comment on the explanations about getting help for commands via the --help option or the man pages is that both won't help you if you do not already know the name of the specific command for your task. Of course, to some extent, that is what the cheat sheet is for. However, when I was a beginner with shell and not used to typing commands or application names instead of just clicking an icon, I frequently only remembered part of a command's name but not the full or correct name. I don't know how often I typed some weird, non-existing palindrome of acroread when I started using shell, until some told me I could just type acr and tab for auto completion!

Therefor, I think it would be useful at some point to explain that the auto completion introduced in Episode 2 for file names, paths or directories also works on commands and application names. A good place to put this, without adding considerable extra time to any of the lessons, would be in Episode 3 Working With Files and Directories, where Nano is introduced as a text editor. After the Which editor? explanation, it would be easy to put something along the lines of "Now what was the name of the editor we were going to use? - It started with na! - So if we type na in the command line and press tab for auto completion, we get a list of all commands and application names staring with na. - There it is: nano!"

I know this is more of a side line than an actual addition to the lesson, but I also think it would be good to make learners aware of this possibility.

hmatthes avatar Jun 30 '20 13:06 hmatthes

I like the suggestion. I find tab-completion to be a crutch I rely on in a big way and it is clearly in the high value, low effort quadrant.

I can imagine some difficulties with getting this to work consistently though:

Inconsistency of output: With the file set included in the lesson, we know exactly which files will work with which prefixes and tab-completion. But with commands, there will be variation among systems in the wild. For example, on my system I have five possible completions for the "na" prefix, so I have to use the double-tab and see a different list than you might.

Possible digression into PATH, environment variables, and startup scripts: I'm anticipating the question: "How can I know which programs on my system will tab-complete?" or similar related questions. The difficulty is that this really depends on the environment which can be difficult to explain and will be inconsistent among systems.

I don't think these are deal-breakers, necessarily. We just have to figure out how to say just the right amount in the lesson and not get caught up in distractions.

matthewabrown avatar Jun 30 '20 20:06 matthewabrown

I would :+1: for a callout explaining this idea and its usefulness, and explicitly call out that there are murky areas we simply won't describe because its out-of-scope. There might be something already in shell-extras about PATH and such, if not, contributions welcome :)

gdevenyi avatar Jul 02 '20 20:07 gdevenyi