Skip to content

Instantly share code, notes, and snippets.

@romgrk
Created October 19, 2015 22:36
Show Gist options
  • Save romgrk/7b607f3d280b1d60ab00 to your computer and use it in GitHub Desktop.
Save romgrk/7b607f3d280b1d60ab00 to your computer and use it in GitHub Desktop.
export ALIASES="$HOME/.aliases'
# CMD and UNCMD are permanent alias
function cmd () {
if [[ $# == 1 ]]; then
print $(alias_value $1)
return 0
fi
if [[ -w $ALIASES ]]; then
print 'alias '$1'="'${@:2}'"' >> $ALIASES
. $ALIASES
else
print "Cant write file $ALIASES"
return 1
fi
}
function uncmd () {
content=$(sed "/^alias $1=/ d" <$ALIASES)
print $content >> $ALIASES
unalias $1
print "deleted command $1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment