lol

dotnet: added shell completion scripts

gbtb 5eca3b06 3eddf315

+43
+11
pkgs/development/compilers/dotnet/common.nix
··· 6 6 , runCommand 7 7 , expect 8 8 , curl 9 + , installShellFiles 9 10 }: type: args: stdenv.mkDerivation (finalAttrs: args // { 10 11 doInstallCheck = true; 11 12 ··· 26 27 export DOTNET_CLI_TELEMETRY_OPTOUT=1 27 28 export DOTNET_SKIP_WORKLOAD_INTEGRITY_CHECK=1 # Skip integrity check on first run, which fails due to read-only directory 28 29 '' + args.setupHook or ""); 30 + 31 + nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ installShellFiles ]; 32 + 33 + postInstall = '' 34 + # completions snippets taken from https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete 35 + installShellCompletion --cmd dotnet \ 36 + --bash ${./completions/dotnet.bash} \ 37 + --zsh ${./completions/dotnet.zsh} \ 38 + --fish ${./completions/dotnet.fish} 39 + ''; 29 40 30 41 } // lib.optionalAttrs (type == "sdk") { 31 42 passthru = {
+13
pkgs/development/compilers/dotnet/completions/dotnet.bash
··· 1 + # bash parameter completion for the dotnet CLI 2 + 3 + function _dotnet_bash_complete() 4 + { 5 + local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n' # On Windows you may need to use use IFS=$'\r\n' 6 + local candidates 7 + 8 + read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null) 9 + 10 + read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur") 11 + } 12 + 13 + complete -f -F _dotnet_bash_complete dotnet
+1
pkgs/development/compilers/dotnet/completions/dotnet.fish
··· 1 + complete -f -c dotnet -a "(dotnet complete (commandline -cp))"
+18
pkgs/development/compilers/dotnet/completions/dotnet.zsh
··· 1 + # zsh parameter completion for the dotnet CLI 2 + 3 + _dotnet_zsh_complete() 4 + { 5 + local completions=("$(dotnet complete "$words")") 6 + 7 + # If the completion list is empty, just continue with filename selection 8 + if [ -z "$completions" ] 9 + then 10 + _arguments '*::arguments: _normal' 11 + return 12 + fi 13 + 14 + # This is not a variable assignment, don't remove spaces! 15 + _values = "${(ps:\n:)completions}" 16 + } 17 + 18 + compdef _dotnet_zsh_complete dotnet