about summary refs log tree commit diff
path: root/pkgs/development/python-modules/jc
diff options
context:
space:
mode:
authorDaniel Nagy <danielnagy@posteo.de>2023-08-10 14:30:00 +0200
committerDaniel Nagy <danielnagy@posteo.de>2023-08-13 15:15:00 +0200
commitf0a3451322f130a516ebe861c45d6955a2a00ab1 (patch)
treeb65ca3efc75d3b5253f71e83883b4217581b1832 /pkgs/development/python-modules/jc
parent44966546d66b394c9f98e320a8b54468485df083 (diff)
jc: add shell completions
Diffstat (limited to 'pkgs/development/python-modules/jc')
-rw-r--r--pkgs/development/python-modules/jc/default.nix11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/jc/default.nix b/pkgs/development/python-modules/jc/default.nix
index 5fdc44912319c..cd6f4060fc968 100644
--- a/pkgs/development/python-modules/jc/default.nix
+++ b/pkgs/development/python-modules/jc/default.nix
@@ -1,6 +1,9 @@
 { lib
+, stdenv
+, buildPackages
 , buildPythonPackage
 , fetchFromGitHub
+, installShellFiles
 , ruamel-yaml
 , xmltodict
 , pygments
@@ -22,6 +25,14 @@ buildPythonPackage rec {
 
   propagatedBuildInputs = [ ruamel-yaml xmltodict pygments ];
 
+  nativeBuildInputs = [ installShellFiles ];
+
+  postInstall = let emulator = stdenv.hostPlatform.emulator buildPackages; in ''
+    installShellCompletion --cmd jc \
+      --bash <(${emulator} $out/bin/jc --bash-comp) \
+      --zsh  <(${emulator} $out/bin/jc --zsh-comp)
+  '';
+
   nativeCheckInputs = [ pytestCheckHook ];
 
   pythonImportsCheck = [ "jc" ];