mkcd: My favourite script

The two commands that I cannot stand to run consecutively are mkdir and cd. It’s a little thing but I despise creating a directory and then entering it with a second command so I wrote a /bin/zsh function to combine them. If you want to do the same add the following into your .zshrc file:

mkcd () {
if [ -z “$1” ] || [ ! -z “$2” ]
then
echo “Usage: mkcd path”
exit 1
fi
mkdir -p “$1” && cd “$1”
}

By Ryan McCoskrie

Founder of the Hurunui Tech Club Creator of Vicinitude President of the Leithfield Public Library

Leave a comment