Created
October 22, 2014 14:57
-
-
Save eftakhairul/a07ebc5958d4447e9251 to your computer and use it in GitHub Desktop.
Create New Alias .bashre Script
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
##------------------------------------ ## | |
# -- new-alias -- # | |
# creates new alias & writes to file # | |
# $1 = alias new # | |
# $2 = alias definition # | |
##------------------------------------ ## | |
new-alias () { | |
if [ -z "$1" ]; then | |
echo "alias name:" | |
read NAME | |
else | |
NAME=$1 | |
fi | |
if [ -z "$2" ]; then | |
echo "alias definition:" | |
read DEFINTION | |
else | |
if [ "$2" = "-cd" ]; then | |
DEFINTION='cd ' | |
else | |
DEFINTION=$2 | |
fi | |
fi | |
echo "alias $NAME='$DEFINTION'" >> ~/.bashrc | |
. ~/.bashrc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment