Skip to content

Repository files navigation

Global Scripts Manager

A command-line tool for managing global scripts across your system. This tool helps you:

  • Create, edit, and delete scripts that can be accessed from anywhere
  • Organize scripts with tags for easy searching
  • Copy script contents to clipboard
  • Open scripts in your preferred editor
  • Track script execution with logs
  • Manage script visibility in your system PATH

Built with Deno, this tool provides an interactive interface to streamline your script management workflow. It maintains a central repository of your scripts while handling all the complexity of making them globally accessible.

Documentation

The landing page source lives in site/ and is deployed to GitHub Pages by .github/workflows/deploy-pages.yaml. In repository settings, set Pages → Build and deployment → Source to GitHub Actions once.

Installation

macOS/Linux: one-command installer

Install the latest release with one command:

curl -fsSL https://raw.githubusercontent.com/aadilmallick/global-scripts-manager/main/install.sh | sh

The installer detects macOS/Linux and x86_64/ARM64, verifies the downloaded binary against the release SHA256SUMS, and installs gsm to ~/.local/bin. Use INSTALL_DIR to choose another location or GSM_VERSION to install a specific tag:

curl -fsSL https://raw.githubusercontent.com/aadilmallick/global-scripts-manager/main/install.sh | INSTALL_DIR=/usr/local/bin GSM_VERSION=1.0.0 sh

Homebrew

After the first versioned release, add the project tap and install GSM:

brew tap aadilmallick/global-scripts-manager https://github.com/aadilmallick/global-scripts-manager.git
brew install gsm

The explicit repository URL is required because this repository is not named with Homebrew's conventional homebrew-* prefix. Once tapped, upgrades work normally with brew upgrade gsm.

The formula selects the correct macOS/Linux x86_64 or ARM64 release asset and verifies it with SHA-256. Homebrew does not support this formula on Windows.

Manual binary download

Download the binary for your platform from the releases page:

  • Linux x86_64: gsm-linux-x86_64
  • Linux ARM64: gsm-linux-aarch64
  • Windows x86_64: gsm-windows-x86_64.exe
  • Windows ARM64: gsm-windows-aarch64.exe
  • macOS Intel: gsm-macos-x86_64
  • macOS Apple Silicon: gsm-macos-aarch64

On macOS/Linux, make it executable and run it:

chmod +x gsm-<platform>
./gsm-<platform>

Or add it to your path for global use (replace the filename with the asset you downloaded):

mv gsm-linux-x86_64 /usr/local/bin/gsm

Verify installation:

which gsm

Register an existing script

Add an existing script file to GSM's managed library:

gsm /path/to/my-script.sh

GSM copies the file into its managed storage and records it in scripts.json. Add --global to also add the managed script folder to your shell PATH:

gsm /path/to/my-script.sh --global

The filename becomes the GSM script name. Supported names contain only letters, numbers, hyphens, and underscores. The command is available for macOS, Linux, and Windows binaries; on Windows use a PowerShell or .exe script filename appropriate to your shell.

Personal learning

Adding cron jobns

You can programmatically add a cron job in Linux by using the crontab command-line tool or scripting languages like Python or Bash.

Method 1: Using crontab

  1. Open the crontab file in the editor: crontab -e
  2. Add the desired cron job:
minute hour day month day_of_week command_to_run

Example:

0 12 * * * /path/to/your/script.sh

This will run the script at 12:00 PM every day.

To add this programmatically, you can use a tool like crontab -l to list all existing cron jobs and then append the new one using >>:

crontab -l >> /etc/crontabs/your_user_name

Replace /etc/crontabs/your_user_name with the actual path where your crontab file is stored.

Method 2: Using Python

You can use Python to add a cron job programmatically. Here's an example script:

import subprocess

def add_cron_job(schedule, command):
    # Get the current user name and home directory
    user_name = subprocess.check_output(['id', '-un']).decode('utf-8')
    home_dir = subprocess.check_output(['pwd']).decode('utf-8')

    # Create a new crontab file
    with open('/etc/crontabs/' + user_name, 'a') as f:
        f.write(schedule + '\n' + command)

# Example usage:
add_cron_job('* * * * * /path/to/your/script.sh', '/bin/sh -c "your_command_here'")

This script uses the subprocess module to get the current user name and home directory, then creates a new crontab file using >>.

Method 3: Using Bash

You can use Bash scripting to add a cron job programmatically. Here's an example:

#!/bin/bash

# Get the current user name and home directory
user_name=$(id -un)
home_dir=$(pwd)

# Create a new crontab file
echo "$user_name" > /etc/crontabs/$user_name

# Append the desired cron job
echo "* * * * * /path/to/your/script.sh" >> /etc/crontabs/$user_name

# Save and close the editor
crontab -e

This script creates a new crontab file using >> and then appends the desired cron job.

Remember to replace /path/to/your/script.sh with the actual path to your script. Also, be aware of security considerations when adding cron jobs programmatically!

About

A CLI tool and server for creating custom scripts, adding them to path, and managing them. All in one place.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages