Hacker News new | ask | show | jobs
by daffy 2118 days ago
One nice thing in zsh is that you can type `/u/lo/b<tab><return>` and be in `/usr/local/bin`.
2 comments

This is one of my primary dislikes of zsh ...
Bash does the same thing here, typing tabs instead of slashes.

    /u<TAB>lo<TAB>b
same number of keystrokes actually
Not quite. Zsh can use the subfolders to disambiguate which parent you meant, bash can't.
Wow. While this is quite slick (and must have been funny to implement), I actually hate this kind of "magic" behavior.
I usually hate magic too, but I have to say this is one of the cases where I like it. It's convenient without any danger attached to it since you're just switching directory and not actually executing something against this "unknown" path.
How is it more or less magic than bash’s? It takes more context into account, sure, but it’s easy to understand and reason about.
For about a decade I've had in my bashrc

    C() { cd `$HOME/path-selector.sh "$@"`; }
where path-selector is from https://github.com/MarcWeber/path-selector

Opt-in bash extensions can do basically whatever people complain bash can't do. Though to be honest I don't use it that much over the last, say, 5 years. If I know a deep directory tree that well, I can just type it explicitly and/or tab complete it without losing much time. If I don't know it that well, FZF is quite nice.

"bash: /usr/local/bin/: Is a directory"

What to you have in your bashrc to allow cd'ing in directories without typing cd?

I prefer to type "cd", the directory-as-executable feature is a bit confusing for me.

But you can enable it in bash, the option has the same name as in zsh: autocd. Just run "shopt -s autocd".