mise icon indicating copy to clipboard operation
mise copied to clipboard

A more generic shell binary manager

Open hoshsadiq opened this issue 1 year ago • 3 comments

Would be cool to have generic binary manager. These often integrate with the shell similar to how rtx activate zsh works, but the difference between those and asdf (and rtx) is that it essentially allows users to define a custom configuration on how to download and set things up. E.g. "download latest release from github releases, and use binary y.

The use-case for these is something like say (go)jq, ripgrep, exa/eza, fzf, etc. The idea being that when you do an update it always gets the latest version (except for when a version is specified).

I currently use zinit to set up my binaries and environment, however, been trying to move away, below is an example with some of the other apps that attempt to address this use-case (though not greatly).

zinit:

zinit ice silent wait as"program" from"gh-r" atload'export FZF_DEFAULT_OPTS="--reverse --exit-0 --border --ansi"'
zinit light junegunn/fzf

afx:

  - name: junegunn/fzf
    owner: junegunn
    repo: fzf
    command:
      build:
        steps:
          - ./install --bin --no-update-rc --no-key-bindings
      link:
        - from: 'bin/fzf'
    plugin:
      sources:
        - shell/completion.zsh
        - shell/key-bindings.zsh
      env:
        FZF_DEFAULT_OPTS: --reverse --exit-0 --border --ansi

bin (untested):

bin install github.com/junegunn/fzf

I've tried a few more out, but I've not been overly happy with the implementations for different reasons.

What I'm proposing here is a generic downloader configured by the user. This should be able to download from different sources (git repo, github/git* releases, http, others?) and furthermore inject some custom stuff into the environment (through rtx activate <shell>). Some preliminary example config I'm thinking of is:

[[package.fzf]]
source = "junegunn/fzf"
from = "gh-r" # or github-release
build = [
  "./install --bin --no-update-rc --no-key-bindings"
]
env = { FZF_DEFAULT_OPTS = "--reverse --exit-0 --border --ansi" }
shell_source = [
    "shell/completion.zsh",
    "shell/key-bindings.zsh"
]
aliases = { fzfa="fzf --no-reverse" }
snippet = """
fzf_doit() {
    fzf "$@"
}
"""

You can imagine that this could become a powerful tool of setting up your dev environment in general. Your repos can specify what tools they need, while users can specify what tools they need on top of those. E.g. I've seen some zinit configurations that set up people's complete shell environments which include neovim + plugins, tmux + plugins, and much more.

hoshsadiq avatar Oct 21 '23 11:10 hoshsadiq

Side note: assuming there's appetite for such a feature, I'd be happy to take a stab at it if I can get some guidance, though I'd need some guidance as I've never developed in Rust before.

hoshsadiq avatar Oct 21 '23 11:10 hoshsadiq

Aren't you pretty much just wanting nix at this point?

Jomik avatar Oct 23 '23 12:10 Jomik

I wouldn't say so no, nix is way overkill for such a task. I just need it to download random archives or binaries and do basic things like linking files or generating completion files.

hoshsadiq avatar Oct 24 '23 17:10 hoshsadiq