5 ms·
This. I would love to be able to type "[command] --[tab]" and have it list all the options, and/or common options, so when I'm learning 'tar' I don't have to st
by ropeladder 9y ago
This. I would love to be able to type "[command] --[tab]" and have it list all the options, and/or common options, so when I'm learning 'tar' I don't have to start typing, realize I've forgotten the command, and then have to go use man or --help or go Google it.
- stevewillows 9y agoHave you checked out ZSH? It can do this nicely.
- signa11 9y agozsh via its ultra-tunable completions can do only 1st part of op's request i.e command option completion, but not the second part i think... for example, i do the following: anupam@virat ~ % autoload -Uz compinit anupam@virat ~ % compinit anupam@virat ~ % git a<TAB> add -- add file contents to index am -- apply patches from a mailbox apply -- apply patch to files and/or to index archimport -- import an Arch repository into git archive -- create archive of files from named tree edit-001: added trivial example.
- mtrycz2 9y agoMy (pretty much vanilla) zsh works quite nicely https://i.imgur.com/SZqu63p.png https://i.imgur.com/SZqu63p.png I'm not sure it covers all of the obscure commands you can think of, but 99% of the time it's great.
- btschaegg 9y agoAs far as I can remember the only standard command I use and that my ZSH has trouble with is `dd`. Luckily, its arguments aren't that complicated.
- asgeir 9y agoMy zsh autocompletion list for git add actually contains the stageable files. I don't know if this is stock zsh behaviour or related to my prezto https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto config but it can be done Edit: looks like it might be stock behaviour https://github.com/zsh-users/zsh/blob/master/Completion/Unix/Command/_git#L47 https://github.com/zsh-users/zsh/blob/master/Completion/Unix...
- ropeladder 9y agoWeird. I'm using Zsh and I swear I've tried that before with nothing happening, but it does actually work. Thanks!
- adambyrtek 9y agoPretty much any modern shell (bash, zsh, fish, etc) provides command line completion.
- skrebbel 9y agoIf you really think the completion in current shells is the best there can be then I think you lack imagination. I don't want remembered commands, I want the terminal to tell me what stuff means. I want it to tell me what makes sense in which context. Like the IntelliSense when coding Java or C#. Docs at your fingertips, all relevant options (and none else) available, etc. This is incomparable to the kind of autocomplete any shell I've seen to date has. Zsh is a nice step in the right direction but it's still shit.
- geoelectric 9y agofish shell does exactly what you say, out of the box. c/p below: ~/.l/share: tar --<tab> --absolute-paths (Don't strip leading /) --after-date (Only store newer files) --append (Append files to archive) --atime-preserve (Keep access time) …and 58 more rows As others have mentioned, zsh can be tuned to perform similarly. fish is nice in that if you don't have explicit completions for options set up it actually parses man pages.
- adambyrtek 9y agoOf course you could always do better, but the specific feature mentioned in the parent comment (completing flags for "tar" instead of checking the man page) has been around for ages. Regarding contextual analysis, the fundamental problem is that command execution relies on a list of strings (argv) with no types or meaning. Each command is responsible for parsing its own arguments, either manually or using a shared library (e.g. getopt). This provides loose coupling and flexibility, but makes introspection really difficult, and features like completions become an afterthought reimplemented in every shell either by special cases for each command or hacks like parsing help messages.