{"id":14235785,"url":"https://github.com/soraxas/shsh","last_synced_at":"2025-04-14T11:32:57.956Z","repository":{"id":89610457,"uuid":"275587479","full_name":"soraxas/shsh","owner":"soraxas","description":"A multi-threaded manager for shell scripts, functions, standalone binaries, tab-completions, and more.","archived":false,"fork":false,"pushed_at":"2024-07-24T04:33:08.000Z","size":572,"stargazers_count":88,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T11:04:27.690Z","etag":null,"topics":["completions","manager","posix-sh","shell-scripts","shsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soraxas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-28T13:10:33.000Z","updated_at":"2025-02-13T07:40:33.000Z","dependencies_parsed_at":"2023-11-23T06:23:20.286Z","dependency_job_id":"ea31024f-ef64-45d2-8e1b-5d6cf7ce1407","html_url":"https://github.com/soraxas/shsh","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soraxas%2Fshsh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soraxas%2Fshsh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soraxas%2Fshsh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soraxas%2Fshsh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soraxas","download_url":"https://codeload.github.com/soraxas/shsh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248872053,"owners_count":21175341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["completions","manager","posix-sh","shell-scripts","shsh"],"created_at":"2024-08-20T21:02:21.290Z","updated_at":"2025-04-14T11:32:57.929Z","avatar_url":"https://github.com/soraxas.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Shsh [![Releases](https://img.shields.io/github/release/soraxas/shsh.svg?label=\u0026color=0366d6)](https://github.com/soraxas/shsh/releases/latest)\n\n\u003cp align=\"center\"\u003e\n   \u003cimg src=\"docs/images/shsh-logo.png\"\u003e\n\u003c/p\u003e\n\nA **sh**ell **s**cripts **h**andler (**shsh**) for managing shell scripts, functions, standalone binaries, completion files, and more.\n\n[![CI](https://github.com/soraxas/shsh/workflows/CI/badge.svg)](https://github.com/soraxas/shsh/actions?query=workflow%3ACI)\n[![ShellCheck](https://github.com/soraxas/shsh/workflows/ShellCheck/badge.svg)](https://github.com/soraxas/shsh/actions?query=workflow%3AShellCheck)\n[![Build Status](https://img.shields.io/travis/soraxas/shsh/master.svg?logo=travis)](https://travis-ci.org/soraxas/shsh)\n[![AUR Version](https://img.shields.io/aur/version/shsh.svg)](https://aur.archlinux.org/packages/shsh)\n[![AUR-git Version](https://img.shields.io/aur/version/shsh-git.svg?label=aur-git)](https://aur.archlinux.org/packages/shsh-git)\n[![Master Update](https://img.shields.io/github/last-commit/soraxas/shsh/master.svg)](https://github.com/soraxas/shsh/commits/master)\n[![License](https://img.shields.io/github/license/soraxas/shsh.svg)](https://github.com/soraxas/shsh/blob/master/LICENSE)\n\n## What it does\n\nShsh allows you to quickly install shell packages directly from github or other sites. Instead of looking for specific install instructions for each package and messing with your `$PATH`, shsh will create a central location for all packages and manage their executable, completions files, and man files for you. It is multi-threaded to speed up updating and setting up your packages.\n\nShsh is a POSIX-compatible script handler, as a former fork of [basher](https://github.com/basherpm/basher) but was made to works with even the most strict POSIX compliance shell like [dash](https://wiki.archlinux.org/index.php/Dash). The performance of shsh is enhanced by using `dash` and with our use of multi-threaded approach. The flexibility of shsh comes from **hooks** where you can run arbitrary scripts that persists across package updates.\n\n## Quick Start\n\n### Automatic Installation\n\nAutomatically bootstrap and install `shsh` (which would also modify your shell's init script)\n```sh\ncurl -s https://raw.githubusercontent.com/soraxas/shsh/master/bootstrap/install.sh | sh\n```\n\n### Pre-made Recipes\n\n`shsh` can retrive pre-made recipes hosted in my [repo](https://github.com/soraxas/shsh-recipes).\nFor example:\n\n```sh\nshsh install -r mamba\n```\n```sh\nshsh install -r git-annex\n```\n\n### Custom Recipes\n\n[Ranger](https://github.com/ranger/ranger): A powerful terminal file manger\n ```sh\nshsh install ranger/ranger -v REMOVE_EXTENSION=true -v BINS=ranger.py -h pre='sed -i \"1d;2i#!/usr/bin/python3 -O\" ranger.py'\n```\n\n\n## Installation\n\n1. **Manual:** Checkout shsh inside `$XDG_DATA_HOME`, e.g., at `~/.local/share/shsh`\n\n   ```sh\n    # clone shsh and add shsh to $PATH variable\n    $ git clone https://github.com/soraxas/shsh ~/.local/share/shsh\n    $ export PATH=\"$HOME/.local/share/shsh/bin:$PATH\"\n    # Optional: link shsh's own completion files and man pages to cellar\n    $ cd ~/.local/share/shsh \u0026\u0026 make self-linking\n   ```\n\n    **Or with AUR (Arch):** Install `shsh` or `shsh-git` pacakage in AUR, e.g.\n\n   ```sh\n    $ yay -S shsh\n   ```\n\n2. Initialise shsh in your shell init file, e.g.\n\n   ```sh\n    # in ~/.bashrc, ~/.zshrc, etc.\n    eval \"$(shsh init SHELL)\"\n    # SHELL: sh, bash, zsh, fish\n   ```\n\n    **Fish**: Use the following commands instead:\n\n   ```fish\n    $ shsh init fish | source\n   ```\n\n## Updating\n\nRun the following command to and pull the latest changes in shsh **(Manual method only)**:\n\n```sh\n$ shsh self-upgrade\n```\n\n## Usage\n\n### Examples\n\n- **Installing remote packages**\n\n  ```sh\n  $ shsh install sstephenson/bats\n  ```\n\n  By default, `shsh` will install package from Github.\n  This will install [bats](https://github.com/sstephenson/bats) and add `bin/bats` to `$PATH`.\n\n  - Installing packages from other sites\n\n    ```sh\n    $ shsh install bitbucket.org/user/repo_name\n    ```\n\n    This will install `repo_name` from https://bitbucket.org/user/repo_name\n\n  - Using ssh instead of https\n\n    If you want to do local development on installed packages and you have ssh\n    access to the site, use `--ssh` to override the protocol:\n\n    ```sh\n    $ shsh install --ssh juanibiapina/gg\n    ```\n\n- **Installing a local package**\n\n  ```sh\n  $ shsh link directory my_namespace/my_package\n  ```\n\n  The `link` command allows you to directly link it to shsh (similar to `pip install -e .`) and any modification to your directory will have an immediate effect.\n\n\n  - The `link` command will install the dependencies of the local package.\n  You can prevent that with the `--no-deps` option:\n\n    ```sh\n    $ shsh link --no-deps directory my_namespace/my_package\n    ```\n\n- **Installing a github release directly (e.g. pre-compiled binary)**\n\n  ```sh\n  $ shsh install --gh-release ajeetdsouza/zoxide FISH_COMPLETIONS=completions/zoxide.fish\n  ```\n\n  The ` --gh-release` flag indicates that you want to directly download and link the binary within github release.\n\n    - You can also pin a release version with:\n\n      ```sh\n      $ shsh install --gh-release junegunn/fzf@0.38.0\n      ```\n\n      which would download from releases with the `0.38.0` tag.\n\n    - If `shsh` is unable to pick the correct asset for you (e.g., the release contains multiple files and it can't determines which to download), you can also specify the asset to download by\n\n      ```sh\n      $ shsh install vslavik/diff-pdf --gh-release=diff-pdf-0.5.tar.gz\n      ```\n\n      which would sort the asset by prioritising asset with the substring `diff-pdf-0.5.tar.gz`.\n\n  **NOTE:** Downloading gh-release has an optional dependency on `jq` (to parse json). If your system does not has `jq`, `shsh` can also attempt to automatically bootstrap `jq` by itself.\n\n\n- **Sourcing files from a package into current shell**\n\n  Basher provides an `include` function that allows sourcing files into the\n  current shell. After installing a package, you can run:\n\n  ```\n  include username/repo lib/file.sh\n  ```\n\n  This will source a file `lib/file.sh` under the package `username/repo`.\n\n### Command summary\n\n- `shsh install \u003cpackage\u003e` - Installs a package from github, custom site, or any arbitrary recipes.\n- `shsh uninstall \u003cpackage\u003e` - Uninstall a package\n- `shsh link \u003cdirectory\u003e` - Installs a local directory as a shsh package\n- `shsh help \u003ccommand\u003e` - Display help for a command\n- `shsh list` - List installed packages\n- `shsh outdated` - List packages which are not in the latest version\n- `shsh upgrade \u003cpackage\u003e` - Upgrade a package to the latest version\n\n### Configuration options\n\nTo change the behavior of shsh, you can set the following variables either\nglobally or before each command:\n\n- If `$XDG_DATA_HOME` is set, `$SHSH_ROOT` will be set as `$XDG_DATA_HOME/shsh`; if not set, `$HOME/.local/share/shsh` is the default.\n . It is used to store cellar for the cloned packages.\n- `SHSH_FULL_CLONE=true` - Clones the full repo history instead of only the last commit (useful for package development)\n- `SHSH_PREFIX` - set the installation and package checkout prefix (default is `$SHSH_ROOT/cellar`).  Setting this to `/usr/local`, for example, will install binaries to `/usr/local/bin`, manpages to `/usr/local/man`, completions to `/usr/local/completions`, and clone packages to `/usr/local/packages`.  This allows you to manage \"global packages\", distinct from individual user packages.\n\n## Packages handling\n\n- Packages are simply repos `username/repo`. You may also specify a site\n`site/username/repo`.\n\n- Any files inside a `bin` directory are added to `$PATH`. If there is no `bin`\ndirectory, any executable files in the package root are added to `$PATH`.\n\n- Any man pages (files ended in `\\.[0-9]`) inside a `man` directory are added\nto the man path.\n\n- Optionally, a repo might contain a `package.sh` file which specifies binaries,\ndependencies and completions in the following format:\n\n  ```sh\n  BINS=folder/file1:folder/file2.sh\n  DEPS=user1/repo1:user2/repo2\n  BASH_COMPLETIONS=completions/package\n  ZSH_COMPLETIONS=completions/_package\n  ```\n\n  BINS specified in this fashion have higher precedence then the inference rules\n  above.\n\n## Recipes for installing packages (in `shshrc`)\n\nThe following are a list of recipes that uses `shsh` plus some lightweight hooks to bootstrap installing script/binaries on a new system. I personally has the following contents in my `~/.config/shshrc` file.\n\nI had defined some handy functions in the `shshrc` file:\n\n```shell\nhas_cmd() {\n  command -v \"$1\" \u003e/dev/null\n}\nis_hostname() {\n  [ $(cat /etc/hostname) = \"$1\" ]\n}\nis_wsl() {\n  cat /proc/version | grep -q '[Mm]icrosoft'\n}\n```\n\n### Examples\n\n- The powerful [delta](https://github.com/dandavison/delta) for viewing diff or git-diff output:\n\n  ```shell\n  # if we have cargo, we can build delta directly\n  has_cmd cargo \u0026\u0026 \\\n    shsh install dandavison/delta -h pre=make -v BINS=target/release/delta\n  ```\n\n- High-level git workflow with [git-town](https://github.com/git-town/git-town)\n\n  ```shell\n  has_cmd go \u0026\u0026 \\\n      shsh install git-town/git-town -h pre='go build \u0026\u0026 ./git-town completions fish \u003e git-town.fish' -v FISH_COMPLETIONS=git-town.fish\n  ```\n\n- Install scripts only on some certain machine\n\n  ```shell\n  # for running bash tests\n  is_hostname Arch \u0026\u0026 \\\n    shsh install bats-core/bats-core\n  ```\n\n- Make sure files has executable bits in **gist**\n\n  ```shell\n  # for opening reverse port\n  shsh install gist.github.com/soraxas/0ef22338ad01e470cd62595d2e5623dd soraxas/open-rev-ports -h a+x\n  ```\n\n- Running post hook for `wsl-open` in **wsl**\n\n  ```shell\n  # script to simulate xdg-open in wsl\n  is_wsl \u0026\u0026 \\\n    shsh install 4U6U57/wsl-open -h post='echo \"*; wsl-open '\"'\"'%s'\"'\"'\" \u003e ~/.mailcap'\n  ```\n\n- Scripts for installing pre-compiled binary for **wsl**\n\n  ```shell\n  is_wsl \u0026\u0026 \\\n    shsh install --plain wsl-tools/win32yank -v _ARCH=x64 -v _VERSION=v0.0.4 -h pre='curl -sLo out.zip https://github.com/equalsraf/win32yank/releases/download/$_VERSION/win32yank-$_ARCH.zip \u0026\u0026 unzip out.zip' -h +x=win32yank.exe\n  ```\n\n## Credits\n\n- [basher](https://github.com/basherpm/basher) for the wonderful framework\n\n- [fisher](https://github.com/jorgebucaran/fisher) for the idea of multi-threaded approach\n\n- [vim-plug](https://github.com/junegunn/vim-plug) for the inspiration of hooks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoraxas%2Fshsh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoraxas%2Fshsh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoraxas%2Fshsh/lists"}