|
1 | 1 | # tool-sync |
2 | | -🧰 Manage your personal toolbox easily |
| 2 | + |
| 3 | +[](https://github.com/chshersh/tool-sync/actions) |
| 4 | +[](https://github.com/chshersh/tool-sync/releases/latest) |
| 5 | +[](LICENSE) |
| 6 | + |
| 7 | +`tool-sync` is a CLI tool for installing your other favourite tools from GitHub Releases. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +> ℹ️ **DISCLAIMER:** `tool-sync` is developed and maintained in free time |
| 12 | +> by volunteers. The development may continue for decades or may stop |
| 13 | +> tomorrow. You can use |
| 14 | +> [GitHub Sponsorship](https://github.com/sponsors/chshersh) to support |
| 15 | +> the development of this project. |
| 16 | +
|
| 17 | +## What it really does? |
| 18 | + |
| 19 | +`tool-sync` embraces the idea that configuring your personal development |
| 20 | +environment should be as easy as possible. And the life is pretty easy when all |
| 21 | +the tools are simple executables. |
| 22 | + |
| 23 | +**So why not simply download all executables you use and put them in one place???** 😱 |
| 24 | + |
| 25 | +With `tool-sync`, you can install all the tools you use by following three |
| 26 | +simple steps: |
| 27 | + |
| 28 | +1. [Install `tool-sync`](#install). |
| 29 | +2. [Configure](#configure) `tool-sync` by listing all the tools you need and |
| 30 | + specifying where to put them. |
| 31 | +3. Run `tool sync`. |
| 32 | + |
| 33 | +That's all! 🥳 |
| 34 | + |
| 35 | +Then `tool-sync` does the following: |
| 36 | + |
| 37 | +* Fetches the information about tools from GitHub Releases |
| 38 | +* Automatically guesses the asset name from your OS for common tools |
| 39 | +* Downloads and unpacks assets |
| 40 | +* Copies binaries from unpacked assets to the location of your choice |
| 41 | + |
| 42 | +## Features |
| 43 | + |
| 44 | +`tool-sync` has several distinguished features that allows you to manage your |
| 45 | +personal toolbox easily: |
| 46 | + |
| 47 | +* Installs the latest version of tools by default. You can easily update all |
| 48 | + your tools with a single command! |
| 49 | +* Supports common tools that you can easily install without extra configuration |
| 50 | +* Automatically guesses asset name from your current OS |
| 51 | +* Configures via a simple TOML file |
| 52 | + |
| 53 | +## Install |
| 54 | + |
| 55 | +### From releases (recommended) |
| 56 | + |
| 57 | +You can install `tool-sync` directly from GitHub releases in a few steps: |
| 58 | + |
| 59 | +1. Go to the [latest release](https://github.com/chshersh/tool-sync/releases/latest). |
| 60 | +2. Download an asset for your OS. |
| 61 | +3. Unpack the `tool` executable to a desired location. |
| 62 | + |
| 63 | +<!-- Good news, you only need to do this once! `tool-sync` will manage future |
| 64 | +installations of itself (if you add it to your config). --> |
| 65 | + |
| 66 | +### From crates |
| 67 | + |
| 68 | +You can use `cargo` to install the latest published version of `tool-sync` from crates: |
| 69 | + |
| 70 | +```shell |
| 71 | +cargo install tool-sync |
| 72 | +``` |
| 73 | + |
| 74 | +### From sources |
| 75 | + |
| 76 | +You can install the latest version of `tool-sync` from sources (requires `git` |
| 77 | +and `cargo`): |
| 78 | + |
| 79 | +```shell |
| 80 | +git clone https://github.com/chshersh/tool-sync |
| 81 | +cd tool-sync |
| 82 | +cargo build --release |
| 83 | +./target/release/tool --version |
| 84 | +``` |
| 85 | + |
| 86 | +## Configure |
| 87 | + |
| 88 | +`tool-sync` reads configuration from a file in TOML format. An example |
| 89 | +configuration file is shown below: |
| 90 | + |
| 91 | +```toml |
| 92 | +# a directory to store all tools |
| 93 | +store_directory = "~/.local/bin" |
| 94 | + |
| 95 | +# the following tools will be installed in 'store_directory' |
| 96 | +[bat] |
| 97 | +[difftastic] |
| 98 | +[exa] |
| 99 | +[fd] |
| 100 | +[ripgrep] |
| 101 | +``` |
| 102 | + |
| 103 | +By default `tool-sync` reads configuration from `~/.tool.toml` but you can put |
| 104 | +the content in any place and specify the path via the `--config` flag. |
| 105 | + |
| 106 | +You can also quickly copy the above configuration to the default path by running |
| 107 | +the following command (Unix-only): |
| 108 | + |
| 109 | +```shell |
| 110 | +curl https://raw.githubusercontent.com/chshersh/tool-sync/main/example-tool-sync-config.toml > ~/.tool.toml |
| 111 | +``` |
| 112 | + |
| 113 | +The above example config lists some tools natively supported by `tool-sync` and |
| 114 | +therefore they don't require extra configuration. |
| 115 | + |
| 116 | +To specify a tool not supported by `tool-sync`, add a TOML table entry and list |
| 117 | +all the required fields like in the example below: |
| 118 | + |
| 119 | +```toml |
| 120 | +[tokei] |
| 121 | +owner = "XAMPPRocky" # GitHub username |
| 122 | +repo = "tokei" # GitHub repository |
| 123 | +exe_name = "tokei" # Executable name inside the asset |
| 124 | + |
| 125 | +# Asset name to download on linux OSes |
| 126 | +asset_name.linux = "x86_64-unknown-linux-musl" |
| 127 | + |
| 128 | +# uncomment if you want to install on macOS as well |
| 129 | +# asset_name.macos = "apple-darwin" |
| 130 | + |
| 131 | +# uncomment if you want to install on Windows as well |
| 132 | +# asset_name.windows = "x86_64-pc-windows-msvc" |
| 133 | +``` |
| 134 | + |
| 135 | +> ℹ️ `tool-sync` searches asset name using the _substring search_. That's why |
| 136 | +> you don't need to specify the full asset name in the config, only the minimal |
| 137 | +> part required for identifying the asset. However, `tool-sync` doesn't guarantee |
| 138 | +> you to find the asset you need if multiple assets from the GitHub release match |
| 139 | +> the substring. |
| 140 | +
|
| 141 | +All fields in each tool section are |
| 142 | + |
| 143 | ++ **required for unknown tools,** |
| 144 | ++ _optional for known tools._ |
| 145 | + |
| 146 | +This means that you can override only some of the fields for known tools. |
| 147 | + |
| 148 | +This can be helpful if e.g. you want to install a custom version of `ripgrep` |
| 149 | +from a forked repository. To do this, specify only the repository owner in the |
| 150 | +config: |
| 151 | + |
| 152 | +```toml |
| 153 | +[ripgrep] |
| 154 | +owner = "me" |
| 155 | +``` |
| 156 | + |
| 157 | +## Usage |
| 158 | + |
| 159 | +Install all the tools specified in `~/.tool.toml`: |
| 160 | + |
| 161 | +```shell |
| 162 | +tool sync |
| 163 | +``` |
| 164 | + |
| 165 | +Install all the tools from config in a different location: |
| 166 | + |
| 167 | +```shell |
| 168 | +tool --config=path/to/my/config.toml sync |
| 169 | +``` |
| 170 | + |
| 171 | +Run `tool --help` for more details. |
| 172 | + |
| 173 | +> :octocat: If you hit the limit for downloading assets or want to download |
| 174 | +> assets from private repositories, |
| 175 | +> [create a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) |
| 176 | +> and export it as the `GITHUB_TOKEN` environment variable. |
| 177 | +
|
| 178 | +## Alternatives |
| 179 | + |
| 180 | +This section contains `tool-sync` comparison to existing alternatives: |
| 181 | + |
| 182 | +1. **Manual download**. You can download GitHub releases manually without using |
| 183 | + any extra tools. |
| 184 | + |
| 185 | + + **Pros** |
| 186 | + + No extra tools required, only your browser and unpack utility |
| 187 | + + **Cons** |
| 188 | + + Tedious manual process |
| 189 | + |
| 190 | +2. **GitHub CLI**. You can download assets from releases using |
| 191 | + [the GitHub CLI tool `gh`][gh]. |
| 192 | + |
| 193 | + ```shell |
| 194 | + gh release download --repo chshersh/tool-sync v0.0.0 --pattern='*linux*' |
| 195 | + tar -xvf tool-x86_64-unknown-linux-gnu.tar.gz |
| 196 | + ./tool --version |
| 197 | + ``` |
| 198 | + |
| 199 | + + **Pros** |
| 200 | + + Using a more common tool (that you probably have) |
| 201 | + + **Cons** |
| 202 | + + Can't download multiple tools with a single command |
| 203 | + + Can't guess the asset name by your OS |
| 204 | + |
| 205 | +3. [**dra**][dra]. `dra` is the closest alternative to `tool-sync`. It's a CLI |
| 206 | + tool, written in Rust, that allows downloading individual releases easily. |
| 207 | + |
| 208 | + + **Pros** |
| 209 | + + Convenient interface for downloading a single release |
| 210 | + + **Cons** |
| 211 | + + Can't download multiple tools with a single command |
| 212 | + + Can't guess the asset name by your OS |
| 213 | + |
| 214 | +4. [**home-manager**][home-manager]. Home Manager provides a full-features |
| 215 | + solution for managing a user environment using the Nix package manager. |
| 216 | + |
| 217 | + + **Pros** |
| 218 | + + Supports more than downloading tools from GitHub Releases |
| 219 | + + Access to the bigger Nix ecosystem |
| 220 | + + **Cons** |
| 221 | + + More complicated solution |
| 222 | + + Requires learning and using Nix |
| 223 | + |
| 224 | +[gh]: https://github.com/cli/cli |
| 225 | +[dra]: https://github.com/devmatteini/dra |
| 226 | +[home-manager]: https://github.com/nix-community/home-manager |
| 227 | + |
| 228 | +## For contributors |
| 229 | + |
| 230 | +Check [CONTRIBUTING.md](https://github.com/chshersh/tool-sync/blob/main/CONTRIBUTING.md) |
| 231 | +for contributing guidelines. |
| 232 | + |
| 233 | +## Development |
| 234 | + |
| 235 | +### Build |
| 236 | + |
| 237 | +Use `cargo` to build the project and run all tests: |
| 238 | + |
| 239 | +```shell |
| 240 | +cargo build |
| 241 | +cargo test |
| 242 | +``` |
| 243 | + |
| 244 | +### Adding a new tool |
| 245 | + |
| 246 | +`tool-sync` contains [a database of common tools][db] and provides easier |
| 247 | +support for them. It's possible to add more tools (and you can suggest them!). |
| 248 | +The following list contains guidelines for including a new tool. They don't |
| 249 | +serve as gatekeeping criteria but more as points system: |
| 250 | + |
| 251 | +* 6 months passed since the tool release |
| 252 | + + So that the database won't be populated with fresh tools that are never |
| 253 | + supported |
| 254 | +* At least 3 releases |
| 255 | + + To ensure stable naming scheme for assets |
| 256 | +* Commonly used tool |
| 257 | + + `tool-sync` strives to be generic so it might not want to support a DNA |
| 258 | + analysis CLI tool which is useful only for a specific group |
| 259 | +* The `tool-sync` author find the tool helpful |
| 260 | + + In the end, there're people behind `tool-sync` who maintain this project |
| 261 | + while the rest of the world benefits from it for free. At least, `tool-sync` |
| 262 | + authors decide what they want to use and whether they want to support a tool indefinitely. |
| 263 | + |
| 264 | +[db]: https://github.com/chshersh/tool-sync/blob/main/src/sync/db.rs |
0 commit comments