oberblastmeister / trashy

a cli system trash manager, alternative to rm and trash-cli
Apache License 2.0
341 stars 13 forks source link

NixOS tab completions don't work at all #120

Open chitoroagad opened 2 months ago

chitoroagad commented 2 months ago

I am using zsh with tmux, powerline10k on nixos and whenever I try to tab complete with anything beginning with trash it simply moves the prompt to a new line, this doesn't happen with trash-cli.

FMGordillo commented 1 month ago

@DariusChit could it be more related to the postInstall?

https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/tools/misc/trash-cli/default.nix#L51 https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/tools/misc/trashy/default.nix

chitoroagad commented 1 month ago

@FMGordillo Sorry for the confusion, tab completions don't work with trash-cli either anymore, both have the same behaviour.

image

FMGordillo commented 1 month ago

Haven't used trash-cli sorry for that! I was facing the same issue with fish until I checked that it works, but not as we expect:

image

using only the trash command doesn't give us autocompletion, but using the right command it does I'm not sure how it works though, but when I ran completion trash in fish I got this

image

So... yeah, probably we should use an alias instead

chitoroagad commented 1 month ago

I see. On zsh there is a similar error for trash put, but all other commands produce similar results to just trash.

image I guess it will teach me to be careful when deleting files.

arminius-smh commented 1 day ago

I believe this was an issue in clap, the Command Line Argument Parser that trashy uses, however this issue was fixed on their side only after the latest release, here is an overlay that is built against the latest commit from 2024-01-19

      (final: prev: {
        trashy = prev.trashy.overrideAttrs (oldAttrs: rec {
          pname = "trashy";
          version = "unstable-2024-01-19";

          src = prev.fetchFromGitHub {
            owner = "oberblastmeister";
            repo = "trashy";
            rev = "7c48827e55bca5a3188d3de44afda3028837b34b";
            sha256 = "sha256-1pxmeXUkgAITouO0mdW6DgZR6+ai2dax2S4hV9jcJLM=";
          };

          # I don't really know what this does I just changed the command name from the existing package
          postInstall = pkgs.lib.optionalString (pkgs.stdenv.buildPlatform.canExecute pkgs.stdenv.hostPlatform) ''
            installShellCompletion --cmd trashy \
              --bash <($out/bin/trashy completions bash) \
              --fish <($out/bin/trashy completions fish) \
              --zsh <($out/bin/trashy completions zsh) \
          '';

          cargoDeps = oldAttrs.cargoDeps.overrideAttrs (prev.lib.const {
            name = "${pname}-vendor.tar.gz";
            inherit src;
            outputHash = "sha256-2QITAwh2Gpp+9JtJG77hcXZ5zhxwNztAtdfLmPH4J3Y=";
          });
        });
      })

applying this fixed the issue for me on zsh (and I'd guess it does on other shells too)

(just keep in mind that the command changed from trash to trashy)