Ever finding yourself doing a mkdir
followed by a cd
into the newly created directory?
Turns out, oh-my-zsh
has a built in function that does both!
Allow me to introduce you to take
…
You can find the source for take
here.
A simple demonstration follows:
take
~ > cd tmp
~/tmp > take some-directory
~/tmp/some-directory >
Nifty, right?
Furthermore, it uses mkdir -p
under the covers, which is idempotent, so if the directory already exists,
it raises no errors, and follows it with a cd
.
Truth be told, I am beating myself up for not having read the source of
oh-my-zsh
for so long!
There are all kinds of nifty functions
and aliases
in there.
If you use oh-my-zsh
then you should definitely take a look; if you don’t then perhaps this will make a convert of
you :)