Reloading functions at shell startup

We can declare as many functions on the Bash interactive shell as we like, but just as functions are only visible during that bash session, they're not persistent either: as soon as the Bash shell in which they were declared exits, they disappear.

If you write a function on the command line that's convenient for you and that you'd like to be available in future sessions, you might want to arrange for that function to be loaded on startup. For most Bash configurations, a good place to put such function declarations is in your ~/.bashrc file. On many systems, such a file may already exist, provided for you with some starting configuration and aliases.

Fortunately, Bash makes it easy to save defined functions ...

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.