From e3b6e5f60f38fae027fb0ed61ff725b092cff3df Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 24 Jul 2019 22:14:14 +0200 Subject: [PATCH] zsh: add just completion --- nix/home-manager/programs/zsh.nix | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/nix/home-manager/programs/zsh.nix b/nix/home-manager/programs/zsh.nix index c94a277..b44fd45 100644 --- a/nix/home-manager/programs/zsh.nix +++ b/nix/home-manager/programs/zsh.nix @@ -7,6 +7,40 @@ let channelSources = (import ../../default.nix { versionsPath = ../../variables/versions.nix; }).channelSources; + + just-plugin = + let + plugin_file = pkgs.writeText "_just" '' + #compdef just + #autload + + alias justl="\just --list" + alias juste="\just --evaluate" + + local subcmds=() + + while read -r line ; do + if [[ ! $line == Available* ]] ; + then + subcmds+=(''${line/[[:space:]]*\#/:}) + fi + done < <(just --list) + + _describe 'command' subcmds + ''; + + in pkgs.stdenv.mkDerivation { + name = "just-completions"; + version = "0.1.0"; + phases = "installPhase"; + installPhase = '' + PLUGIN_PATH=$out/share/oh-my-zsh/plugins/just + mkdir -p $PLUGIN_PATH + cp ${plugin_file} $PLUGIN_PATH/_just + chmod --recursive a-w $out + ''; + }; + in { programs.zsh = { enable = true; @@ -78,6 +112,10 @@ in { name = "minikube"; src = "${pkgs.oh-my-zsh}/share/oh-my-zsh/plugins/minikube"; } + { + name = "just"; + src = "${just-plugin}/share/oh-my-zsh/plugins/just"; + } ]; oh-my-zsh = { enable = true;