comma: install completion (#530309)
This commit is contained in:
@@ -36,26 +36,44 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
||||
--replace-fail '"fzy"' '"${lib.getExe fzy}"'
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
ln -s $out/bin/comma $out/bin/,
|
||||
postInstall =
|
||||
let
|
||||
emulator = stdenv.hostPlatform.emulator buildPackages;
|
||||
in
|
||||
''
|
||||
ln -s $out/bin/comma $out/bin/,
|
||||
|
||||
mkdir -p $out/share/comma
|
||||
mkdir -p $out/share/comma
|
||||
|
||||
cp $src/etc/command-not-found.sh $out/share/comma
|
||||
cp $src/etc/command-not-found.nu $out/share/comma
|
||||
cp $src/etc/command-not-found.fish $out/share/comma
|
||||
cp $src/etc/command-not-found.sh $out/share/comma
|
||||
cp $src/etc/command-not-found.nu $out/share/comma
|
||||
cp $src/etc/command-not-found.fish $out/share/comma
|
||||
|
||||
patchShebangs $out/share/comma/command-not-found.sh
|
||||
substituteInPlace \
|
||||
"$out/share/comma/command-not-found.sh" \
|
||||
"$out/share/comma/command-not-found.nu" \
|
||||
"$out/share/comma/command-not-found.fish" \
|
||||
--replace-fail "comma --ask" "$out/bin/comma --ask"
|
||||
''
|
||||
+ lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
|
||||
${stdenv.hostPlatform.emulator buildPackages} "$out/bin/comma" --mangen > comma.1
|
||||
installManPage comma.1
|
||||
'';
|
||||
patchShebangs $out/share/comma/command-not-found.sh
|
||||
substituteInPlace \
|
||||
"$out/share/comma/command-not-found.sh" \
|
||||
"$out/share/comma/command-not-found.nu" \
|
||||
"$out/share/comma/command-not-found.fish" \
|
||||
--replace-fail "comma --ask" "$out/bin/comma --ask"
|
||||
''
|
||||
+ lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
|
||||
${emulator} "$out/bin/comma" --mangen > comma.1
|
||||
installManPage comma.1
|
||||
|
||||
installShellCompletion --cmd comma \
|
||||
--bash <(${emulator} $out/bin/comma --print-completions bash) \
|
||||
--fish <(${emulator} $out/bin/comma --print-completions fish) \
|
||||
--zsh <(${emulator} $out/bin/comma --print-completions zsh)
|
||||
|
||||
# TODO: Add , to other shells too
|
||||
cat >>$out/share/zsh/site-functions/_comma <<'EOF'
|
||||
if [ "$funcstack[1]" = "_comma" ]; then
|
||||
_comma "$@"
|
||||
else
|
||||
compdef _comma ,
|
||||
fi
|
||||
EOF
|
||||
'';
|
||||
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
doInstallCheck = true;
|
||||
|
||||
Reference in New Issue
Block a user