by jetpm · 11y ago · 0 comments
ali <name of alias> <command>
to get it put this in your .bashrc
function ali() {
echo "alias $1='${@:2}'" >> ~/.bashrc #in ubuntu use ~/.bash_aliases
echo "made alias:";
echo "alias $1='${@:2}'";
source ~/.bashrc; #reload bashrc
}
When I realize I type a command often, I just push the up arrow to get the command again, append "ali" infront of it and turn it to an alias. Works direclty.And of course the alias to show the list of all aliases:
alias alis='cat ~/.bash_aliases'That only lists what's in .bash_aliases, along with any comments.
Why not just run alias without arguments? It lists all active aliases, however and whenever they were defined.
$ man bash
/^SHELL BUILTIN COMMANDS
...
alias [-p] [name[=value] ...]
"Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output."