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

I am a nerd trapped in the country side of North Canterbury, New Zealand trying to get an IT-related career off of the ground. Legal disclaimer: Ryan McCoskrie is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com I'm also signed up with Fishpond but they aren't as strict about this stuff.

Leave a comment