]> git.phdru.name Git - dotfiles.git/commitdiff
.shellrc: add function mkcd
authorOleg Broytman <phd@phdru.name>
Sun, 2 Aug 2015 15:56:41 +0000 (18:56 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 2 Aug 2015 15:56:41 +0000 (18:56 +0300)
.shellrc

index 85ca29e03d700b4abaa0db0b38288077388c9aac..eb741b1345c1124b90dc9bc7a96ece9ffe7c3357 100644 (file)
--- 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"