trash-cli: use installShellCompletion

This commit is contained in:
wzy 2023-04-04 04:15:12 +08:00 committed by Robert Helgesson
parent 8634641676
commit f7cb50b3cf

View File

@ -1,4 +1,4 @@
{ lib, fetchFromGitHub, python3Packages }:
{ lib, fetchFromGitHub, installShellFiles, python3Packages }:
python3Packages.buildPythonApplication rec {
pname = "trash-cli";
@ -13,6 +13,11 @@ python3Packages.buildPythonApplication rec {
propagatedBuildInputs = with python3Packages; [ psutil six ];
nativeBuildInputs = with python3Packages; [
installShellFiles
shtab
];
nativeCheckInputs = with python3Packages; [
mock
pytestCheckHook
@ -44,13 +49,10 @@ python3Packages.buildPythonApplication rec {
runHook postInstallCheck
'';
postInstall = ''
for bin in trash{,-{empty,list,put,restore}}; do
$out/bin/$bin --print-completion bash > $bin
install -Dm644 $bin -t $out/share/bash-completion/completions
$out/bin/$bin --print-completion zsh > _$bin
install -Dm644 _$bin -t $out/share/zsh/site-functions
$out/bin/$bin --print-completion tcsh > $bin.csh
install -Dm644 $bin.csh -t $out/etc/profile.d
for bin in trash-empty trash-list trash-restore trash-put trash; do
installShellCompletion --cmd "$bin" \
--bash <("$out/bin/$bin" --print-completion bash) \
--zsh <("$out/bin/$bin" --print-completion zsh)
done
'';