Make and jump into directory easily
Very often - like ALL the time - you end up creating a new directory with mkdir -p some_path
and then immediately typing cd some_path
right after. Such a waste of typing!
Here’s a super handy little function that does both things at once. Just drop this in your config and thank me later:
For Fish:
function mkcd
mkdir -p $argv[1]; and cd $argv[1]
end
For those that have to still learn that Fish is the best shell, here’s Bash and ZSH:
mkcd() {
mkdir -p "$1" && cd "$1"
}
Now you can just type mkcd ~/.config/test
and boom - directory created and you’re already inside it! The -p
flag means it’ll create any missing parent directories too, so you can go as deep as you want. Way better than typing two commands every single time, right?