Created
November 30, 2011 03:05
-
-
Save ryo1kato/1407796 to your computer and use it in GitHub Desktop.
useful shell functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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