Skip to content

Instantly share code, notes, and snippets.

@psachin
Last active August 29, 2015 14:01
Show Gist options
  • Save psachin/fc674b216d99ac4eca92 to your computer and use it in GitHub Desktop.
Save psachin/fc674b216d99ac4eca92 to your computer and use it in GitHub Desktop.
Make and change directory.
function mcd()
{
# Make and change directory.
# Optionally initialize it as a GIT repo.
# Copy this function to ~/.bashrc or /etc/profile
if [ "$#" -eq 1 ]
then
echo "Do you want to initialize this as a git repo? "
select ynq in "Yes" "No" "Quit"; do
case $ynq in
Yes) git init "$1"; cd "$1"
break;;
No) mkdir --parents "$1"; cd "$1"
break;;
Quit) echo "Bye."
break;;
esac
done
else
echo "Usage: mcd <DIR_NAME>" > /dev/stderr
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment