A CLI to organize and run short Unix shell scripts
A central repository to manage all your one-liners, scripts, tools, and CLIs. Add, remove, list, and run scripts - storing metadata to easily find them later. No more digging through your bin folder...
If you've spent any amount of time in the terminal you no doubt have built up a lovely collection of one-liners, scripts, useful tools, and CLIs. Whenever you want to use them you dig through your bin folder trying to remember what you called the script... Linux users love hard-to-remember naming conventions.
Scripts should be first-class citizens. In a GUI world we can find our programs using a menu of sorts. In the terminal scripts get lost.
The idea behind pier is to create a central repository for all your scripts, and provide a way to attach metadata about these scripts. Using pier you can add, remove, list, and run scripts. These can be managed by pier in a human-readable TOML config, or you can use it to catalog existing scripts that you may have lying around - you'd then simply add the metadata for the specific script, and attach it to the name in the PATH.
From Crates.io: cargo install pier
From GitHub release: simply download the release binary
Using Nix package manager:
make install or nix-env -if derivation.nixsrc in derivation to ./.0.1.4:The configuration variable default_interpreter has been removed:
default_interpreter = ["foorunner", "-c"]So when upgrading from to 0.1.4 from an earlier version you will need to instead specify the variable in this format:
[default]
interpreter = ["foorunner", "-c"]Use pier --help to display help on commandline or see src/cli.rs for a more detailed spec.
…pier listpier add "ip link set wlp58s0 down && sleep 5 && ip link set wlp58s0 up" --alias refresh-wifipier refresh-wifipier TOML config[scripts.refresh-wifi]
command = "ip link set wlp58s0 down && sleep 5 && ip link set wlp58s0 up"
[scripts.twa-analyze]
command = "docker run --rm -t trailofbits/twa -vw"
tags = [ "infosec" ]
[scripts.enabled-services]
command = "systemctl list-unit-files --state=enabled"
[scripts.flush-docker]
command = "docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumes"
description = "A script to clear out old Docker containers and images"
tags = [ "docker", "flush" ]pier list output…Scripts starting with a shebang #! will be run with the specified interpeter just like it would in a normal script. Pier does this by creating a temp file from your script, executing it and then finally cleaning the file up. This allows you to write your pier script in python, node.js etc. even compiled languages can be run if using something like scriptisto.
[scripts.run_rust_script]
command = '''
#!/usr/bin/env scriptisto
// scriptisto-begin
// script_src: src/main.rs
// build_cmd: cargo build --release && strip ./target/release/script
// target_bin: ./target/release/script
// files:
// - path: Cargo.toml
// content: |
// package = { name = "script", version = "0.1.0", edition = "2018"}
// [dependencies]
// scriptisto-end
fn main() {
println!("This is a rust script!");
}
'''
[scripts.run_python]
command = '''
#!/usr/bin/env python3
import sys
print("Running python with version {}".format(sys.version))
'''By default if no shebang is specified pier will try to use your default shell to execute the script inline. This can be overwritten with the variable interpreter. It needs to be a list with the first item being the binary and the rest is any flags necessary.
# Sets the default interpreter, the first item in the list should be the binary and the rest are the arguments for the interpreter cli option.
[default]
interpreter = ["node", "-e"]
# Runs as the fallback interpreter nodejs as it's lacking a shebang
[scripts.hello_world_nodejs]
command = '''
console.log("Hello world!")
'''
# This will be run as a posix sh script as it has a shebang
[scripts.a_shell_script]
command = '''
#!/bin/sh
nohup st > /dev/null 2>&1&
'''Originally intended as a way to manage Docker one-liners, the name pier continues along the same maritime theme. I realized Pier can manage a lot more than just Docker scripts.
No open issues yet, or sync has not completed.