From: Oleg Broytman Date: Sun, 2 Aug 2015 15:56:41 +0000 (+0300) Subject: .shellrc: add function mkcd X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=41552ba848ec72fd207ae6fba1ab97b55574c2f6;p=dotfiles.git .shellrc: add function mkcd --- diff --git a/.shellrc b/.shellrc index 85ca29e..eb741b1 100644 --- a/.shellrc +++ b/.shellrc @@ -138,6 +138,19 @@ include() } +function mkcd { + if [ $# -ne 1 ]; then + echo "Usage: mkcd directory_name" >&2 + elif [ -d "$1" ]; then + cd "$1" + elif [ -e "$1" ]; then + echo "Error: $1 is a file" >&2 + else + mkdir -p "$1" && cd "$1" + fi +} + + mc() { if [ -n "$SLOWTERM" ]; then MC_SLOW="--slow"