mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
dotnet: added shell completion scripts
This commit is contained in:
parent
3eddf3150a
commit
5eca3b06e7
@ -6,6 +6,7 @@
|
||||
, runCommand
|
||||
, expect
|
||||
, curl
|
||||
, installShellFiles
|
||||
}: type: args: stdenv.mkDerivation (finalAttrs: args // {
|
||||
doInstallCheck = true;
|
||||
|
||||
@ -27,6 +28,16 @@
|
||||
export DOTNET_SKIP_WORKLOAD_INTEGRITY_CHECK=1 # Skip integrity check on first run, which fails due to read-only directory
|
||||
'' + args.setupHook or "");
|
||||
|
||||
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ installShellFiles ];
|
||||
|
||||
postInstall = ''
|
||||
# completions snippets taken from https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete
|
||||
installShellCompletion --cmd dotnet \
|
||||
--bash ${./completions/dotnet.bash} \
|
||||
--zsh ${./completions/dotnet.zsh} \
|
||||
--fish ${./completions/dotnet.fish}
|
||||
'';
|
||||
|
||||
} // lib.optionalAttrs (type == "sdk") {
|
||||
passthru = {
|
||||
tests = let
|
||||
|
13
pkgs/development/compilers/dotnet/completions/dotnet.bash
Normal file
13
pkgs/development/compilers/dotnet/completions/dotnet.bash
Normal file
@ -0,0 +1,13 @@
|
||||
# bash parameter completion for the dotnet CLI
|
||||
|
||||
function _dotnet_bash_complete()
|
||||
{
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n' # On Windows you may need to use use IFS=$'\r\n'
|
||||
local candidates
|
||||
|
||||
read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)
|
||||
|
||||
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
|
||||
}
|
||||
|
||||
complete -f -F _dotnet_bash_complete dotnet
|
@ -0,0 +1 @@
|
||||
complete -f -c dotnet -a "(dotnet complete (commandline -cp))"
|
18
pkgs/development/compilers/dotnet/completions/dotnet.zsh
Normal file
18
pkgs/development/compilers/dotnet/completions/dotnet.zsh
Normal file
@ -0,0 +1,18 @@
|
||||
# zsh parameter completion for the dotnet CLI
|
||||
|
||||
_dotnet_zsh_complete()
|
||||
{
|
||||
local completions=("$(dotnet complete "$words")")
|
||||
|
||||
# If the completion list is empty, just continue with filename selection
|
||||
if [ -z "$completions" ]
|
||||
then
|
||||
_arguments '*::arguments: _normal'
|
||||
return
|
||||
fi
|
||||
|
||||
# This is not a variable assignment, don't remove spaces!
|
||||
_values = "${(ps:\n:)completions}"
|
||||
}
|
||||
|
||||
compdef _dotnet_zsh_complete dotnet
|
Loading…
Reference in New Issue
Block a user