Last active
September 29, 2016 11:54
-
-
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
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"