You have 2 free member-only stories left this month.
A New Simple Package Manager for Script Languages
A painless tool to manage installation and uninstallation
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 ~/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/bin:$PATH' >> ~/.zshrc
Or add the following to your terminal config file, such as .zshrc
or .bashrc
.
export PATH=$HOME/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
Limitations
The Awesome package manager creates a ~/awesome
and ~/bin
directory if they don’t exist. When you install a repo, it clones to the ~/awesome
directory and creates a symlink in the ~/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
.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.
If you like my article and would like to receive my newsletter, please sign up.