Thesola10 / zsh-comma-assistant

Supercharge your zsh with the true power of Nix!
4 stars 0 forks source link

Add support for `sudo` (and other prefix commands) #5

Open Thesola10 opened 2 years ago

Thesola10 commented 2 years ago

Adding support for sudo and such would actually involve pulling the binary path from the Nix store and patching it into the first argument for the prefixed command. Not only does that require reimplementing comma functionality into the plugin itself, it also depends on proper command detection and replacement -- instead of hijacking command_not_found, the plugin would edit the command line itself, requiring a zle widget.

Thesola10 commented 2 years ago

We could substitute command names in place, allowing for universal support, by using nix build nixpkgs#attr to populate the path, then nix eval --raw nixpkgs#attr to retrieve and patch it in.

The zle widget will basically be the next generation of comma-assistant, without comma, so maybe I could call it zsh-nix-assistant instead?

Thesola10 commented 2 years ago

Being able to hook directly into the build+eval system would even allow us to speed up command relaunching compared to comma, as well as retain some offline functionality/show a useful message along the lines of <command>: could not build using nix