I have an alias called save_aliases that does alias > ~/.bash_aliases. alias on its own just dumps all the existing aliases to the terminal in a format that can be parsed by Bash.
I felt especially clever when I came up with that and used it to save itself.
Bonus fact: ${BASH_ALIASES["name-here"]} is a way to get at the contents of an alias without resorting sed or cut shenanigans on the output of the alias command.
I have an alias called
save_aliasesthat doesalias > ~/.bash_aliases.aliason its own just dumps all the existing aliases to the terminal in a format that can be parsed by Bash.I felt especially clever when I came up with that and used it to save itself.
Bonus fact:
${BASH_ALIASES["name-here"]}is a way to get at the contents of an alias without resortingsedorcutshenanigans on the output of thealiascommand.