# sht / short / 🩳 [![Crate](https://img.shields.io/crates/v/short.svg)](https://crates.io/crates/short) ![status](https://img.shields.io/static/v1?label=status&&message=not%20stable&color=orange&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAADuUlEQVRoge1ZS2gUWRQ99/VHNCOCikZGB5yFO4kfoiAoyuBoOm13dbDjb+PCz2ZWImKCuhGTncJsRBFmXESxI3aVnY6jcREFRdEYVPwQFdz5GRT8REnSXddFYlPVdHVev6omiHWgoOq+9+49p+t97q0GfPjw4WMiQU4NLW13+Pt9e2u9Y7+JhphoAm4RrHRANK39wcDfBNSAeG+XZpyvBjFZSE0h9B8s3A7EJmHol8Kwd6/ezprTt/vkSLUIjoeKp5Bplzyjdvabes/YKEBqCrV3/legHd0WPwvGZkvzagA3PeYljcoXsSmuWR+JaY1nbBTg+AaEyTFT0AkAc6x2Bq4VLZwVDd0Nky5FLg05+eLuhrmg0DGA142ZehDg/fRn1zN16mM8nRqOHFiWAQJ1BHRa7dlE+imANxbTFDEcXubkZ5R88D7AGwFMHbuakKdbnIn+6pJ/+SnU3rrk/7bW+mabkcBEuG5nSasdnVDoGIDpJVqmI0hHZYk6QekgY5Ns60CUXQeFaVMK5dqkoCYAsAlg4pVRPZ5w7l49KAnIJtKPALy1mILEdM5BxFVnT9SjEt8KtVyIwMy0z2piIFRShJlvAfCuhJf3ILQoxbdAOZnLNqVPA2i32kqJoMbuAeS4DkAKwMfRi86DaDmtv/hcNX7Bv6vRDGrUtQ4CthQ5HWHiTV2akXblXwKu8/xkKjn5a2ikF4DtLGBiFiZ6mcggpr6hmsH+K+uuDLqNVwxPCpVIKlkrQiO3AfxWplsewBMG7gqm50LQY0O74PoNeVZpRfT4QsF0A6MnrRQYSGU1fTNIfav1rCLr1oyHBGzC6C8tBQKaG3XtLzdxPa91I2mtTaCi7fErMy3NNqWfqMTzvCYWxE8rHDKZiDuSqWRYKZ7KoLJgqlMYtfhLePiQSrhqfJWQE8C4Z30kppaIEVtVabAJE8CCW0H82spFmOLfmBGT3sUAjwXE9fg8ADMluppThsM3GNgOe7Y638wHKqoRPBWQBxZJdn3R2dz5OasZl5nppK2FeEdUj2+UjempAGaSFfCgQCCU2wNgwO6IjkdSyVoZR54KIMn5T0wFAZkNmS8MbCXA+nFsZiA8/A94/HPKawGyb+C+9SGb0PtMYntqzrS+Udd2jufIMwExIzaVgd+lOgdzD4pNg9M+HCbgttVGwNHIhcSCcq48E8D5QB3kUpNPmQ2Zl8XG3jW9uRywDcBni7mGiDuWntgVcnLmOhdau3VHVYv27+g5c6ok1x/+/wFfgA8fPnz83PgG8Ekdaq6qdi0AAAAASUVORK5CYII= ) [![linux](https://github.com/vincent-herlemont/short/workflows/linux/badge.svg)](https://github.com/vincent-herlemont/short/actions?query=workflow%3Alinux) [![osx](https://github.com/vincent-herlemont/short/workflows/osx/badge.svg)](https://github.com/vincent-herlemont/short/actions?query=workflow%3Aosx) [![azure releases](https://img.shields.io/azure-devops/build/vincentherlemont/short_deploy/1/master?label=releases&logo=azure-pipelines)](https://dev.azure.com/vincentherlemont/short_deploy/_build?definitionId=1) [![dicord](https://img.shields.io/static/v1?label=join&message=Discord&color=7289da&&logo=Discord)](https://discord.gg/AnVYgJM) > A concise cli launcher / project manager using env files. The main goal it's readability and time saving with commands use in your project. Short it's command-line tool that allow to run program (usually sh script) with environment variables mapping from .env files. It is like to run `eval $(.env_file) ./script.sh` with more options. - It take care to **synchronize** and to **check** the format of all [**environment files**](#environment-file-environment_name) to each other. - [**Prompt infos**](#configure-prompt) : You always known which is your current [**setup**](#setup) and [**environment**](#environment-file-environment_name). - Allow multiple [**setups**](#setup) in the same [**project**](#project-shortyaml). - Allow to store example of **no critical** environment file in your source code with a [**public env directory**](#public-directory). - Allow to store prod/stage/etc.. and **critical** environment file in your source code with a [**private env directory 🔒**](#private-directory-). - You can apply a mapping in order to [**select**, **group** and add **custom formats / cases**](#arrayvars) on the fly on the [environment variables](#variables). - The result of mapping will be **inject** as [environment variables](#variables) in the output .sh script that will be executed. ![short global workflow](./docs/img/short_global_workflow.png) # Install This product is in alpha but for personal use it is reasonably stable. ### ArchLinux AUR : [short-git](https://aur.archlinux.org/packages/short-git/) ``` git clone https://aur.archlinux.org/short-git.git cd short-git makepkg -si ``` ### Homebrew (OSX,Linux) ``` brew install vincent-herlemont/tap/short ``` ### From sources Require for compilation : [libgit2](https://libgit2.org/), [openssl](https://www.openssl.org/). ``` cargo install short ``` ### Configure prompt It's really recommended to configure the prompt. That allow to known every time which [**setup**](#setup) and [**environment**](#environment-file-environment_name) are selected. You can see the command [`show`](#show-your-current-setup--environment) for more details.
✨ PS1 (BASH/ZSH) Example with PS1 configure by `.bashrc` ```shell script export PS1="$(sht show -f):\w\$ " ``` Example with PS1 configure by `.zshrc` ```shell script ⚠️ TODO ... ```
✨ starship Example with [custom pre-prompt : **starship**](https://starship.rs/advanced-config/#custom-pre-prompt-and-pre-execution-commands-in-bash). Here the custom script that starship run before display prompt. ```shell script #!/bin/bash function blastoff(){ sht show -f } starship_precmd_user_func=blastoff ``` Preview: ``` $> [my_setup:my_env] ~/your_project$ ```
### Quick start blank ✍️ Generate a simply **sh** script who display variables. You can use this base for what as you want. See [`generate`](#generate-setup) for more details. ``` sht generate ``` ``` $> sht init $> sht generate setup_1 test sh -d $> sht run ``` `-d`: create a sub directory (optional). ### Quick start with template 🚀
🌱 Example with Node && ExpressJs Generate a simply aws sam project base on this template [node-express](https://github.com/vincent-herlemont/node-express-short-template). See [`generate`](#generate-setup) for more details. Requirement : You have installed [node](https://nodejs.org/) and [npm](https://www.npmjs.com/). ``` $> sht init $> sht generate node-express -d -t $> sht run ``` `-t`: generate from template. `-d`: create a sub directory _(optional)_.
🌱 Example with AWS SAM Generate a simply aws sam project base on this template [aws-node-sam](https://github.com/vincent-herlemont/aws-node-sam-short-template). See [`generate`](#generate-setup) for more details. Requirement : You have installed [SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) and [AWS_CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html). ``` $> sht init $> sht generate aws-node-sam -d -t $> sht run ``` `-t`: generate from template. `-d`: create a sub directory _(optional)_.
You can list all templates available with `sht generate -l` and add a new one [**here**](https://github.com/vincent-herlemont/short-template-index/blob/master/readme.md#add-template-and-share-with-the-community). ---- - [Commands](#commands) - [`init` project](#init-project) - create an empty project - [`generate` setup](#generate-setup) - generate a setup inside a project - [`run` setup](#run-setup) - 🚀 - [`rename` setup](#rename-setup) - rename a setup - [`new` env](#new-env) - create new env file - [`sync` env](#sync-env) - sync env files - [`edit` env](#edit-env) - edit an env file - [`dir` env directory](#dir-env-directory) - set/unset a public env directory - [`pdir` env private directory](#pdir-env-private-directory) - set/unset a private env directory - [`use` select/switch your setup/environment](#use-selectswitch-your-setupenvironment) - [`show` your current setup / environment](#show-your-current-setup--environment) - [`ls` list all setups and environments](#ls-list-all-setups-and-environments) - [`vars` display/compare mapping environment variables](#vars-displaycompare-mapping-environment-variables) - [`envs` display/compare environment variables](#envs-displaycompare-environment-variables) - [Configuration file `short.yaml`](#configuration-file-shortyaml) - [Concepts](#concepts) - [Setup](#setup) - [Directories (public/private)](#directories-publicprivate) - [Environment file `.`](#environment-file-environment_name) - [Variables](#variables) # Commands ### `init` project. Create an empty [`short.yaml`](#configuration-file-shortyaml) configuration file. This one define the your project directory. All `short` command inside of this folder and child's folders take for references this configuration file. ``` $> sht init ``` _[short.yaml](#configuration-file-shortyaml) (generated)_ ```yaml setups: {} ``` ### `generate` setup. Generate an **empty** setup or a setup from a **project templates [repository](https://github.com/vincent-herlemont/short-template-index/blob/master/readme.md)**, this command can be also list all available project templates.
✍ Generate an empty setup ️ | Arguments | Required | Description | | ---------- | -------- | ----------- | | | yes | Setup name | | | yes | Env name | | \ | yes | File kind [sh,bash ...] | | Options | [Allow empty*](#option-allow-empty) | Default | Description | | ---------- | -------- | ------- | ----------- | | -d , --directory | yes | | Target directory. | | -p , --private| no | false | 🔒 Save to private directory. _[conflict with "-d"]_ | | -f , --file| no | run.sh | Path script, create directory if they miss. _[conflict with "-d"]_ | | -e , --env-directory| no | . | Public env directory. _[conflict with "-d"]_ | Example : create a setup named `my_setup` with `.test` environment file and `bash` script. ``` $> sht generate my_setup test bash ``` _short.yaml (generated)_ : Configuration file. ``` setups: my_setup: file: run.sh array_vars: all: pattern: ".*" case: CamelCase format: "[{key}]='{value}'" delimiter: " " vars: [] ``` _.test (generated)_ : Environment file. ``` VAR1=VALUE1 VAR2=VALUE2 ``` _run.sh (generated)_ : Runnable file. ``` #!/bin/bash declare -A all && eval all=($ALL) declare -p all ``` The seconds line `declare -A all && eval all=($ALL)` allow to use **[bash associative array](https://www.gnu.org/software/bash/manual/html_node/Arrays.html)**.
🌱 List all project templates ``` $> sht generate -l ```
🌱 Generate setup from projects template | Arguments | Required | Description | | ---------- | -------- | ----------- | | | yes | Setup name or \