O'Reilly logo

bash Cookbook by Cameron Newham, JP Vossen, Carl Albing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Self-Contained, Portable RC Files

Problem

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.

Solution

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, "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, "Getting Started with a Custom Configuration" for a sample to get you started.

Discussion

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

Assumptions

  • You have a complex environment in which you control some, but ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required