Bootstrap your Linux terminal session

When you start a Linux terminal session (aka shell session), you always (or very very often) want to apply some customization to it. For instance:

  • Set the PATH or PS1 variable
  • Set a proxy
  • Add aliases
  • Write a configuration file for a particular command (e.g. vim’s .vimrc, screen’s .screenrc)
  • Apply mandatory initialization process for a particular command line (e.g. jenv, nvm or rbenv)
  • and so on

Even, you want to apply all those settings for a given period, and apply other ones for another, as if you wanted to deal with shell session profiles.

shprofile to the rescue

I’m developing a tool, shprofile, that helps you to bootstrap your shell session by managing a set of shell session profiles. A profile contains a set of scripts which are executed any time the profile is loaded. Examples of scripts can be found here.

This way, your shell session can be customized at any time, event at its opening by putting shprofile at the shell session startup.

shprofile can be seen as a combined version of /etc/profile.d (because of its modular architecture) and .bash_profile (because focusing on a single user), by adding the ability to:

  • define several profiles
  • not being constraint to use a shell type specific user profile file (e.g., .bash_profile or .zprofile)

How does it works?

Each shell profile is defined by a set of scripts contained into its associated entry from the $HOME/.shprofile/profiles folder. An entry is simply a folder that is named as the profile’s name.

For instance:

$HOME/
    .shprofile/
        profiles/
            myfirstprofile/
                script1.sh
                script2.sh
            mysecondprofile/
                script3.sh
                script4.sh    

defines two profiles myfirstprofile and mysecondprofile containing respectively the script1.sh, script2.sh and the script3.sh, script4.sh scripts.

Once a profile is defined, it can be simply loaded via:

$ shprofile myfirstprofile

and be switched by an other one via:

$ shprofile mysecondprofile

Available features

  • Manage different shell profiles
  • Be able to define several scripts into a same profile, allowing then to modularize shell profiles’ scripts (e.g., 1 script for 1 tool) and easily import or export them
  • Apply the lexicographical order when discovering shell profiles’ scripts
  • Allow to define loading and unloading shell profile script types to handle transition between profiles
  • Remember the current profile in use to be able to quickly reload it

To conclude

shprofile is designed for those who want to get rid of personal shell session customization. It offers a modular solution to manage your shell initialization process and let you define profile to enable a specific configuration at a time.

Check out the Github project for more information!