Skip to content

Instantly share code, notes, and snippets.

@scottzirkel
Created May 2, 2016 01:36
Show Gist options
  • Save scottzirkel/a4d1c6f50ac07d60c2bc46b5cfab05bd to your computer and use it in GitHub Desktop.
Save scottzirkel/a4d1c6f50ac07d60c2bc46b5cfab05bd to your computer and use it in GitHub Desktop.
Make directory then CD in
function mkcd {
if [ ! -n "$1" ]; then
echo "Enter a directory name"
elif [ -d $1 ]; then
echo "\`$1' already exists"
else
mkdir $1 && cd $1
fi
}
@scottzirkel
Copy link
Author

Just a quick little function for your bashrc/zshrc/whateverrc file.

mkcd dirname and you are instantly in your brand new dir (if it exists).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment