Skip to content

Instantly share code, notes, and snippets.

@eftakhairul
Created October 22, 2014 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eftakhairul/a07ebc5958d4447e9251 to your computer and use it in GitHub Desktop.
Save eftakhairul/a07ebc5958d4447e9251 to your computer and use it in GitHub Desktop.
Create New Alias .bashre Script
##------------------------------------ ##
# -- 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