1

Oh-my-zsh has the take command which creates a directory and enters into it in one step. Is there an equivalent command for the fish shell?

I do know that I can do it with mkdir newDir && cd newDir, but I like the shorter, more convenient version that Oh-my-zsh provides.

1 Answer 1

4

Not built-in, but very easy to reproduce:

function take
    mkdir -p "$argv[1]"; and cd "$argv[1]"
end

funcsave take

This will create a lazy-load function in $HOME/.config/fish/functions/take.fish. By "lazy-load", we mean that the function isn't loaded when Fish starts, but only the first time you run the take command. So it's always available, but only takes up memory when you run it.

2
  • 1
    I'd recommend and cd in case mkdir fails. Nov 21, 2021 at 22:31
  • @glennjackman Great point - Thanks! Edited. Could probably go one step further and still cd if the directory already exists. Not sure what the oh-my-zsh behavior is. Nov 21, 2021 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.