Skip to content

Instantly share code, notes, and snippets.

@looneym
Last active September 29, 2016 11:54
Show Gist options
  • Save looneym/94b94d0b67734d47893e37f195a42ae4 to your computer and use it in GitHub Desktop.
Save looneym/94b94d0b67734d47893e37f195a42ae4 to your computer and use it in GitHub Desktop.
Utility for easily creating aliases from the command line. Can manually specify commands or use -l flag to read last item in bash_history
#!/usr/bin/env bash
# -l flag uses last command from history file instead
if [ $1 == -l ]
then
full=`awk 'END{print}' ~/.bash_history`
echo "Enter the short command to alias"
read short
echo "alias "$short"='$full'" >> ~/.bash_profile
source ~/.bash_profile
exit 0
fi
echo "Enter the short command to alias"
read short
echo "Enter the full command"
read full
echo "alias "$short"='$full'" >> ~/.bash_profile
source ~/.bash_profile
@looneym
Copy link
Author

looneym commented Sep 29, 2016

Alias this script in your bash_profile to use this from the command line (change path to match where you put the file):

alias mkal="~/.butils/make_alias"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment