Re:How to navigate directories faster with Bash (2015)
by W0lf on Thursday April 22, 2021 @05:16AM
(#26900549)
For this exact use case I defined the following many years ago in my bash profile:
And use it like: mkd foo
[ Parent
| on HN ]
Re:How to navigate directories faster with Bash (2015)
by mfontani on Thursday April 22, 2021 @08:46AM
(#26902114)
Beware that using "$@" there might not be what you want, as it passes space-separated arguments to mkdir.
What does: "mkd foo bar" do? It creates both directories, and cd's into "bar".
Might be worth checking that only one argument has been passed, or use "$*" which instead would treat all arguments as one parameter, and "mkd foo bar" would create a "foo bar" directory instead (and cd to it)
YMMV.
Re:How to navigate directories faster with Bash (2015)
by W0lf on Thursday April 22, 2021 @03:17PM
(#26906931)
Thanks a lot for pointing this out. I will happily fix this now!
Re:How to navigate directories faster with Bash (2015)
by dvfjsdhgfv on Thursday April 22, 2021 @10:05AM
(#26902891)
All Bash manuals and tutorials should start from explaining this issue. And I really mean it. I can't remember how many times I was bitten by it until I finally read it up.
Re:How to navigate directories faster with Bash (2015)
by mfontani on Thursday April 22, 2021 @12:45PM
(#26904870)
I feel one should also install shellcheck, and follow it religiously while looking up every warning they get - to understand what it's about, why it's a problem, and why the solution / "correct" incantation is so.
It's also a good way to "learn by doing", which works for many.