paint-brush
The “Nano-Framework” For Adding Scripts To Your .{bash/zsh}rc Filesby@b0noi
410 reads
410 reads

The “Nano-Framework” For Adding Scripts To Your .{bash/zsh}rc Files

by Viacheslav KovalevskyiJanuary 3rd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

How many times have you seen a repo with a custom RC installer of .bashrc or .zshrc files? Repos with a file, like these:
featured image - The “Nano-Framework” For Adding Scripts To Your .{bash/zsh}rc Files
Viacheslav Kovalevskyi HackerNoon profile picture

How many times have you seen a repo with a custom RC installer of .bashrc or .zshrc files? Repos with a file, like these:

Examples are numerous, since everyone is reinventing a wheel. I have done it once or twice. So eventually, I have decided to write my own “nano-framework” that solves exactly this problem and that can be used with any config out there. Here is how the README.md for my config repo looks like:

In order to install config please do:

cd /tmpgit clone https://github.com/OwnInfrastructure/configs.gitcd configsRC_PATH=.commonrccurl -s https://raw.githubusercontent.com/b0noI/rcinstaller/master/install.sh | bash /dev/stdin $RC_PATH

The main line that I want to bring to your attention is the following:

curl -s https://raw.githubusercontent.com/b0noI/rcinstaller/master/install.sh | bash /dev/stdin $RC_PATH

This is the example of a usage of the “rcinstaller”, the “nano-framework” that installs script to the .bashrc and/or .zshrc. The home repo of the framework is here.

Now anyone can just create a config repo with configs and use this framework in a README file to describe the installation without re-implementing the wheel.

How I Can Use It?

It is simple, just add something like the following to your README file:

curl -s https://raw.githubusercontent.com/b0noI/rcinstaller/master/install.sh | bash /dev/stdin <path_to_my_awesome_rc_file>

How Does the “rcinstaller” Work?

Overall, the script executes the following steps:

  1. checks if the ~/.profile.d directory exists and if not — created it;
  2. adds “[ -f ${HOME}/.profile.d/.sh ] && source ${HOME}/.profile.d/.sh” to the .zshrc (if it is not exists there already);
  3. same for the .bashrc;
  4. copies the rc file from the input (or .commonrc if there is no input) from the current directory to the: ~/.profile.d.

Currently, it requires your rc files to have a unique name. This is needed simply because the script will overwrite whatever is in the file with the same name. Also, it works only with one input script at a time.

How I Can Help?

If you would like to help, there are some feature requests and issues that need to be implemented, any help would be highly appreciated. You can add a star to the repo as well, or just share the article with your friends.

Also I have the Patreon page;)