4 ms·
Bash's sadly flawed smart (programmable) completion
- soraminazuki 3y agoI wonder what the author thinks of zsh. Unlike bash, zsh completion just works. It's context-aware, properly completes subcommands and options, and doesn't suffer from the problem explained in the article. It even shows descriptions for each of the completion candidates. In contrast, bash almost always falls back to filename completion for the most common commands even when third party frameworks like bash-completion are installed. It's frustrating when I have to deal with interactive bash sessions because, sigh, Docker.
- siproprio 3y agoyeah, zsh is just superior. it can even emulate bash!
- throwiforgtnlzy 3y agoYes. 15+ year zsh user here. When dealing with bash, try to sneak in PackageKit-command-not-found and bash-completion. And when running a shell, do it like this: docker run user/image:tag -it --rm bash -li Also, zshdb, bashdb, and shellcheck are good stuff™ too. My mantra is all programs and widely-used company tools should have current man pages and shell completions. The whole "Go look at a web page" for "help" is slow, distracting, and lazy.
- amluto 3y ago> PackageKit-command-not-found This one is so pathetically slow on Fedora that I find it counterproductive. Also, at least as of a year or two ago (I haven’t checked since then), PackageKit maintained its own, large, cache, thus wasting a surprising amount of space in /var.
- throwiforgtnlzy 3y agoIt depends. It's better than nothing that can be ^C'ed. Here's a naive, partial implementation that runs in <500 ms so long as there's an existing dnf cache: command_not_found_handle() { local pkgs readarray pkgs < <(dnf rq --whatprovides "$1" -C --qf '%{name}\n' 2>/dev/null | sed '/^$/d' | sort -uVr) if (( ! "${#pkgs[@]}" )); then echo >&2 'Command not found and no package provides it according to the dnf cache' return fi echo >&2 'Command not found, but offered via the following command(s):' pkgs=("${pkgs[@]/#/ dnf install }") echo >&2 " ${pkgs[@]}" }
- mdaniel 3y agowow, the discipline required to blog every day with that much substance
- nullc 3y agoBash's completion has caused me to waste a lot of time operating on the wrong file because it "knew" something was the only match based on the format when it really wasn't. Didn't know about M-/ -- handy to have a solution that works on other people's systems.
- gkfasdfasdf 3y agoWhat key-combination produces M-/?
- pulpfictional 3y agohttps://github.com/akinomyoga/ble.sh https://github.com/akinomyoga/ble.sh This revolutionizes Bash's user experience.
- 1oooqooq 3y agoi just spent hours trying to hack systemclt's autocomplete sonit lists service names case insensitively (because they have less consistency than php methods)... only to be stoped by a hack that was already in place for something else on the original files that called the builtins methods again and then it became too hacky.
- plowjockey 3y agoI read much on zsh, but I seem to be too invested in Bash to change. Is there are good migration guide for someone with a moderately complex ~./bashrc and a lot of aliases in ~/.bash_aliases? I seem to recall doing an Arch installation a couple of years back and the zsh instance was well done but none of that setup was installed on the system even with zsh installed. I suppose I could have copied it from the installation media but didn't think about that at the time.