Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created November 30, 2011 03:05
Show Gist options
  • Save ryo1kato/1407796 to your computer and use it in GitHub Desktop.
Save ryo1kato/1407796 to your computer and use it in GitHub Desktop.
useful shell functions
mkcdir(){
mkdir -p "$@"
if [ "$1" = "-p" ]; then
cd "$2"
else
cd "$1"
fi
}
mvcd () {
err () { echo "mvcd: ERROR: $*" >&2 }
[ $# -lt 2 ] && { err "too few arguments"; return 1; }
eval 'local newdir=$'"$#"
[ -d $newdir ] || { err "$newdir is not a directory"; return 1; }
mv "$@"
cd $newdir || { err "cannot get into $newdir directory"; return 1; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment