Code Monkey home page Code Monkey logo

droplet.sh's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.