Skip to content

💧 Bootstrap of my shell world. Import shell scripts like Golang.

License

Notifications You must be signed in to change notification settings

ggicci/droplet.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

droplet.sh

Bootstrap of my shell world. Import shell scripts like Golang.

Getting Started

curl -sSLO "https://raw.githubusercontent.com/ggicci/droplet.sh/v0.1.0/droplet.sh"

Use "droplet"

First, you have to source the droplet.sh (WARNING):

source droplet.sh

then you can use droplet rather than source to import well-organized shell scripts:

droplet "bar.sh" # => source "{lookfor_paths}/bar.sh"
droplet "github.com/ggicci/droplets/time.sh" # => source "{lookfor_paths}/github.com/ggicci/droplets/time.sh"
droplet "/tmp/mutable.sh" # => source the absolute path

The lookfor_paths

droplet.sh will find the scripts you wish to import in several paths (lookfor_paths) by order:

  1. .;
  2. ./droplets directory;

Organize Your Shell Scripts

Create a repository e.g. github.com/ggicci/droplets, in which save your reuseable shell scripts. Then droplet it in another project. Demo:

mkdir /tmp/demo-project && cd $_

# Get droplet.sh in the project.
curl -sSLO "https://raw.githubusercontent.com/ggicci/droplet.sh/v0.1.0/droplet.sh"

# Save 3rd-party reusable shell scripts (dependencies, libraries?) into
# "droplets" subfolder.
mkdir -p droplets/github.com/ggicci/droplets
git clone https://github.com/ggicci/droplets.git droplets/github.com/ggicci/droplets

# Create sample snippet:
echo '#!/usr/bin/env bash

set -euo pipefail

source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/droplet.sh"
droplet "github.com/ggicci/droplets/time.sh"

time::now
' > demo.sh

chmod u+x demo.sh
./demo.sh

# Output:
# 2021-07-04T14:33:38+08:00

Environment Variables

  • DROPLET_DEBUG=1: enable debug output

WARNING

ONLY import trusted shell scripts.

About

💧 Bootstrap of my shell world. Import shell scripts like Golang.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages