Creating Self-Contained, Portable RC Files


You work on a number of machines, some of which you have limited or full root control over, and some of which you do not, and you want to replicate a consistent bash environment while still allowing custom settings by operating system, machine, or other (e.g., work, home) criteria.


Put all of your customizations in files in a settings subdirectory, copy or rsync that directory to a location such as ~/ or /etc, and use includes and symbolic links (e.g., ln -s ~/settings/screenrc ~/.screenrc) as necessary. Use logic in your customization files to account for criteria such as operating system, location, etc.

You may also choose not to use leading dots in the filenames to make it a little easier to manage the files. As you saw in Showing All Hidden (dot) Files in the Current Directory, the leading dot causes ls not to show the file by default, thus eliminating some clutter in your home directory listing. But since we’ll be using a directory that exists only to hold configuration files, using the dot is not necessary. Note that dot files are usually not used in /etc either, for the same reason.

See Getting Started with a Custom Configuration for a sample to get you started.


Here are the assumptions and criteria we used in developing this solution:


  • You have a complex environment in which you control some, but not all, of the machines you use.

  • For machines you control, one machine exports /opt/bin and all other machines ...

Get bash Cookbook 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.