avatarShinichi Okada

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

4454

Abstract

v id="9108"><pre>awesome install alexanderepstein<span class="hljs-regexp">/Bash-Snippets cheat/</span>cheat</pre></div><p id="ec59">After the <code>username/reponame</code>, add the <code>subfolder/scriptname</code>.</p><h1 id="4555">Removing a package</h1><p id="cfd5">You can remove a package using <code>rm</code>:</p><div id="187f"><pre>awesome <span class="hljs-built_in">rm</span> cleanit</pre></div><h1 id="db52">List packages</h1><p id="f673">You can list installed packages using <code>ls</code> :</p><div id="58c0"><pre>awesome <span class="hljs-built_in">ls</span></pre></div><h1 id="436d">Update a package</h1><p id="3a51">You can update a package using <code>update</code>:</p><div id="0861"><pre><span class="hljs-attribute">awesome update gistart</span></pre></div><h1 id="6edf">Alias</h1><p id="a0f2">You can create an alias. First, install a package:</p><div id="3db8"><pre>awesome install shinokdaa/backpack_install</pre></div><p id="bfe2">Use <code>-a</code> to set an alias with the repo name and script name:</p><div id="42b0"><pre>awesome alias <span class="hljs-keyword">bi </span><span class="hljs-keyword">backpack_install </span><span class="hljs-keyword">backpack_install</span></pre></div><p id="a8eb">This creates an alias <code>bi</code> for <a href="https://github.com/shinokada/backpack_install">backpack_install</a>.</p><h2 id="a006">Multiple scripts</h2><p id="7dac">When a repo has multiple files, you can create aliases.</p><p id="118e">First, install the main script.</p><div id="57f5"><pre>awesome <span class="hljs-keyword">install </span><span class="hljs-keyword">shinokada/script-examples </span>php-example.php</pre></div><p id="5cc0">The script-examples repo has multiple scripts. Let’s create an alias with another script.</p><div id="7e22"><pre>awesome alias <span class="hljs-keyword">ne</span> script-examples <span class="hljs-keyword">node</span><span class="hljs-title">-example</span>.js</pre></div><p id="b2f7">or</p><div id="4bf7"><pre>awesome <span class="hljs-built_in">alias</span> re <span class="hljs-keyword">script</span>-examples ruby-example.rb</pre></div><p id="055b">When you run <code>ne</code>, it will run <code>node-example.js</code> and <code>re</code> run <code>ruby-example.rb</code>.</p><h1 id="6aa6">Git add, commit, push, and update</h1><p id="6e42">When you are working on a script, you need to run a bunch of Git commands and update the local package. Use <code>push</code>:</p><div id="cfec"><pre>awesome <span class="hljs-built_in">push</span> <span class="hljs-string">"your commit message"</span></pre></div><p id="0fe3">This will run Git add, commit, push, and awesome update commands.</p><h1 id="dd0d">Uninstalling Awesome</h1><p id="d7eb">You can uninstall Awesome using <code>curl</code>:</p><div id="6d65"><pre>curl -s https:<span class="hljs-regexp">//</span>raw.githubusercontent.com<span class="hljs-regexp">/shinokada/</span>awesome<span class="hljs-regexp">/main/i</span>nstall > tmp1 && bash tmp1 uninstall && rm tmp1</pre></div><p id="a2e2">Or <code>wget</code>:</p><div id="101e"><pre>wget -qO - https:<span class="hljs-regexp">//</span>raw.githubusercontent.com<span class="hljs-regexp">/shinokada/</span>awesome<span class="hljs-regexp">/main/i</span>nstall > tmp1 && bash tmp1 uninstall && rm tmp1</pre></div><h1 id="4dd1">Some scripts you can install using Awesome</h1><p id="38bc">(<a href="https://github.com/shinokada/awesome/blob/main/list.md">See the full list</a>)</p> <figure id="600d"> <div> <div>

            <iframe class="gist-iframe" src="/gist/shinokada/95880c294f46d24c5189ff69b7779a68.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
          </div>
        </div>
    </figure></iframe></div></div></figure><h1 id="c2bf">Limitations</h1><p id="c699">The Awesome package manager creates a <code>~/.local/share/awesome</code> and <code>~/.local/share/bin</code> directory if they don’t exist. When you install a repo, it clones to the <code>~/.local/share/awesome</code> directory and creates a symlink in the <code>~/.local/share/bin</code> directory.</p><p id="6dc7">The Awesome package manager is suitable for small scripts. A repo with a main script and library scripts should be fine to install. But if a repo needs dependencies, then generally they provide a Makefile, install file, or other methods t

Options

o install the repo. The Awesome won’t install the dependencies.</p><h1 id="ca96">How to create a script with other languages</h1><p id="cc3b">When you want to create a script, use shebang at the top of the file.</p><p id="d42a">Some shebang <a href="https://github.com/shinokada/script-examples">examples</a> are:</p><div id="30a5"><pre><span class="hljs-meta">#!/usr/bin/env node</span> <span class="hljs-meta">#!/usr/bin/env perl</span> <span class="hljs-meta">#!/usr/bin/env php</span> <span class="hljs-meta">#!/usr/bin/env python3</span> <span class="hljs-meta">#!/usr/bin/env ruby</span></pre></div><h1 id="d76d">Conclusion</h1><p id="08c0">When you want to install scripts without dependencies, the Awesome package manager is a handy tool. It makes it easy to install and uninstall scripts from GitHub repos.</p><p id="33cf">If you are interested in creating your own bash script, you may be interested in reading the article “<a href="https://betterprogramming.pub/best-practices-for-bash-scripts-17229889774d">Best Practices for Bash Scripts</a>” by <a href="undefined">Akshay Kapoor</a>.</p><p id="f9a2">I’d like to hear what you think about the Awesome package manager. If you know any of the repositories you can use with the Awesome, please let me know.</p><p id="d04b">Please see more details on<a href="https://github.com/shinokada/awesome"> the Github repo</a>.</p><p id="2459">Happy coding.</p><p id="a7b7"><b>Get full access to every story on Medium by <a href="https://blog.codewithshin.com/membership">becoming a member</a>.</b></p><figure id="fc8b"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*DjTM9iFtVc2wlcWcOms7VQ.png"><figcaption><a href="https://blog.codewithshin.com/subscribe">https://blog.codewithshin.com/subscribe</a></figcaption></figure><div id="6cc6" class="link-block"> <a href="https://readmedium.com/how-to-use-manop-to-print-only-selected-content-from-the-man-page-11309b9efa38"> <div> <div> <h2>Save Time Using Manop to Print Only Selected Content From the Man Page</h2> <div><h3>Manop is a simple Bash script that outputs an option and a description</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*uRuvZLSXeaCZAPz6fGTGtQ.png)"></div> </div> </div> </a> </div><div id="e034" class="link-block"> <a href="https://betterprogramming.pub/how-to-automate-homebrew-installs-on-your-new-mac-or-linux-51e06881c5b7"> <div> <div> <h2>How To Automate Homebrew Installs on Your New Mac or Linux</h2> <div><h3>You don’t need to install Homebrew packages one by one</h3></div> <div><p>betterprogramming.pub</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*OPHiwGh1voiqa70-qDg_mA.png)"></div> </div> </div> </a> </div><div id="82d5" class="link-block"> <a href="https://readmedium.com/how-to-automate-cleaning-up-your-trash-and-downloads-directory-1ac2815b2089"> <div> <div> <h2>How to Automate Cleaning up Your Trash and Downloads Directory</h2> <div><h3>Set a cleanup schedule on macOS with a single line of code</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*u1vYLfSoknldTrk3)"></div> </div> </div> </a> </div><div id="f84e" class="link-block"> <a href="https://readmedium.com/automate-creating-a-github-repo-with-a-line-of-code-on-linux-f21fb2aafebd"> <div> <div> <h2>Automate Creating a Github Repo With a Line of Code on Linux</h2> <div><h3>Introducing updated version of Gitstart</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*aqVBagG2CYVRGhjp)"></div> </div> </div> </a> </div></article></body>

A New Simple Package Manager for Script Languages

A painless tool to manage installation and uninstallation

Image by Author.

[Update: 2021–07–15]

Introduction

Most programming languages provide a package manager for easy installation. It can be apt, rpm, npm, yum, pip, brew, gem, cargo, go, composer, etc.

But sometimes there are small shell scripts you have to install manually. You have to clone or download a repo, make it executable, and add a path in your terminal configuration, such as .bashrc, zshrc, etc.

Awesome is the name of my simple script package manager. It installs a script from a GitHub repo to your macOS/Linux.

The scripting language is a series of commands that execute without the need for compiling. Bash, Lua, Node, Perl, Php, Python, Python3, Ruby are some of them. The Awesome package manager allows you to share your scripts with your team members for a quick view through a Github repository.

Let’s install the Awesome package manager.

Installing Awesome package manager

It is easy to install awesome.

If you use curl:

curl -s https://raw.githubusercontent.com/shinokada/awesome/main/install | bash -s install

If you use wget:

wget -qO - https://raw.githubusercontent.com/shinokada/awesome/main/install | bash -s install

We need to export the ~/.local/share/bin directory to the PATH variable. Run the following to add a PATH to your terminal config file, such as .zshrc or .bashrc.

echo 'export PATH=$HOME/.local/share/bin:$PATH' >> ~/.zshrc

Or add the following to your terminal config file, such as .zshrc or .bashrc.

export PATH=$HOME/.local/share/bin:$PATH

Installing a package

To install a package, use the install option. When the main script and GitHub repository name is the same, use username/reponame:

awesome install shinokada/manop.git

Once you installed a repo, you can use it:

manop grep -v
       -v, --invert-match
              Invert the sense of matching, to select non-matching lines.

You can use URL or HTTPS to install a repo:

# Using URL
awesome install https://github.com/shinokada/cleanit
# or using HTTPS
awesome install https://github.com/shinokada/abi.git

In case the main script name is different from the repository name, use username/reponame mainscript as the previous example. Another example is tldr, it has the repository name tldr-sh-client:

awesome install raylee/tldr-sh-client tldr

The Bash snippets repository has many subfolders.

awesome install alexanderepstein/Bash-Snippets cheat/cheat

After the username/reponame, add the subfolder/scriptname.

Removing a package

You can remove a package using rm:

awesome rm cleanit

List packages

You can list installed packages using ls :

awesome ls

Update a package

You can update a package using update:

awesome update gistart

Alias

You can create an alias. First, install a package:

awesome install shinokdaa/backpack_install

Use -a to set an alias with the repo name and script name:

awesome alias bi backpack_install backpack_install

This creates an alias bi for backpack_install.

Multiple scripts

When a repo has multiple files, you can create aliases.

First, install the main script.

awesome install shinokada/script-examples php-example.php

The script-examples repo has multiple scripts. Let’s create an alias with another script.

awesome alias ne script-examples node-example.js

or

awesome alias re script-examples ruby-example.rb

When you run ne, it will run node-example.js and re run ruby-example.rb.

Git add, commit, push, and update

When you are working on a script, you need to run a bunch of Git commands and update the local package. Use push:

awesome push "your commit message"

This will run Git add, commit, push, and awesome update commands.

Uninstalling Awesome

You can uninstall Awesome using curl:

curl -s https://raw.githubusercontent.com/shinokada/awesome/main/install > tmp1 && bash tmp1 uninstall && rm tmp1

Or wget:

wget -qO - https://raw.githubusercontent.com/shinokada/awesome/main/install > tmp1 && bash tmp1 uninstall && rm tmp1

Some scripts you can install using Awesome

(See the full list)

Limitations

The Awesome package manager creates a ~/.local/share/awesome and ~/.local/share/bin directory if they don’t exist. When you install a repo, it clones to the ~/.local/share/awesome directory and creates a symlink in the ~/.local/share/bin directory.

The Awesome package manager is suitable for small scripts. A repo with a main script and library scripts should be fine to install. But if a repo needs dependencies, then generally they provide a Makefile, install file, or other methods to install the repo. The Awesome won’t install the dependencies.

How to create a script with other languages

When you want to create a script, use shebang at the top of the file.

Some shebang examples are:

#!/usr/bin/env node
#!/usr/bin/env perl
#!/usr/bin/env php
#!/usr/bin/env python3
#!/usr/bin/env ruby

Conclusion

When you want to install scripts without dependencies, the Awesome package manager is a handy tool. It makes it easy to install and uninstall scripts from GitHub repos.

If you are interested in creating your own bash script, you may be interested in reading the article “Best Practices for Bash Scripts” by Akshay Kapoor.

I’d like to hear what you think about the Awesome package manager. If you know any of the repositories you can use with the Awesome, please let me know.

Please see more details on the Github repo.

Happy coding.

Get full access to every story on Medium by becoming a member.

https://blog.codewithshin.com/subscribe
Package Manager
Bash
Coffee2021
Script Language
Shell
Recommended from ReadMedium