I want to make an alias for a multiline command to call it faster then copying-pasting-executing it from a text file each time.
An example for such command is this execute-a-remote-updater command:
(
cd "${program_to_update_dir}"
wget https://raw.githubusercontent.com/USER/PROJECT/BRANCH/update.sh
source update.sh
rm update.sh
)
A couple of years ago I have learned that multiline commands' aliases are impossible due to Bash design limitations but perhaps since then the program has been changed and now it is possible.
I think that if it is still impossible, perhaps I could make a function with that code, export it to all shell sessions (although I rarely work with any subsessions and I don't even recall when I last did that), and then call it somehow.
Should it be enough and secure to just wrap it in an export
ed and named function in say .bashrc
or .bash_profile
and then call it whenever I need to?
$PATH
and calling that vs writing those lines in an alias and calling that. Bonus 1: your script will be so much easier to comment and maintain. Bonus 2: your .bashrc will be so much easier to maintain. Aliases have their uses, but for anything above a certain very minimal complication level, I would use a script.