📜 ⬆️ ⬇️

“Nano-Framework” to automate the addition of scripts to. {Bash / zsh} rc

How often did you see a repository with a custom script for installing your scripts .bashrc or .zshrc files? I definitely wrote such a bike and more than once, for repositories where I store my personal configs. Let's solve this problem.



Examples of such bikes are darkness:


I think you wrote a similar bike. So it occurred to me to generalize this matter. The quick search gave no results and I wrote my own craft. Maybe something similar already exists, but so far no one has indicated this to me. Here is the README.md file of my repository with configs now:
')
In order to install config please do:

cd /tmp git clone https://github.com/OwnInfrastructure/configs.git cd configs RC_PATH=.commonrc curl -s https://raw.githubusercontent.com/b0noI/rcinstaller/master/install.sh | bash /dev/stdin $RC_PATH 

It is important to pay attention here:

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

This is an example of using the same framework called “rcinstaller”. A repository with it can be found here .

Now you only need to create configs, and you can leave their integration to this craft.

How to start using it on your repository


It doesn't get any simpler, just add something like this to your README file:

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

What does this thing do?


At the time of this writing, the script ran a simple list of steps:

  1. Checks if the ~ / .profile.d directory exists, and if not, creates it.
  2. Add to .zshrc (if there is no such thing yet): “[-f $ {HOME} /. Profile.d / .sh] && source $ {HOME} /. Profile.d / .sh”.
  3. Same for .bashrc.
  4. Copies the given script to ~ / .profile.d.

As you might guess, your config should have a unique name, as the script stupidly overwrites an existing file with the same name. So far, only one script is supported at a time.

How can you help the project


If you want to help - there is a list of tasks and bugs . And of course you can go to my page on Patreon .

ATTENTION!


Good people have already explained to me that such use of curl may not be completely safe .

Source: https://habr.com/ru/post/319000/


All Articles