mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-29 11:20:10 +00:00
installShellFiles: Add nushell support to installShellCompletion (#428168)
This commit is contained in:
@@ -58,8 +58,8 @@ The `installShellCompletion` function takes one or more paths to shell
|
||||
completion files.
|
||||
|
||||
By default it will autodetect the shell type from the completion file extension,
|
||||
but you may also specify it by passing one of `--bash`, `--fish`, or
|
||||
`--zsh`. These flags apply to all paths listed after them (up until another
|
||||
but you may also specify it by passing one of `--bash`, `--fish`, `--zsh`, or
|
||||
`--nushell`. These flags apply to all paths listed after them (up until another
|
||||
shell flag is given). Each path may also have a custom installation name
|
||||
provided by providing a flag `--name NAME` before the path. If this flag is not
|
||||
provided, zsh completions will be renamed automatically such that `foobar.zsh`
|
||||
@@ -77,9 +77,10 @@ zsh).
|
||||
# explicit behavior
|
||||
installShellCompletion --bash --name foobar.bash share/completions.bash
|
||||
installShellCompletion --fish --name foobar.fish share/completions.fish
|
||||
installShellCompletion --nushell --name foobar share/completions.nu
|
||||
installShellCompletion --zsh --name _foobar share/completions.zsh
|
||||
# implicit behavior
|
||||
installShellCompletion share/completions/foobar.{bash,fish,zsh}
|
||||
installShellCompletion share/completions/foobar.{bash,fish,zsh,nu}
|
||||
'';
|
||||
}
|
||||
```
|
||||
@@ -104,6 +105,7 @@ failure. To prevent this, guard the completion generation commands.
|
||||
installShellCompletion --cmd foobar \
|
||||
--bash <($out/bin/foobar --bash-completion) \
|
||||
--fish <($out/bin/foobar --fish-completion) \
|
||||
--nushell <($out/bin/foobar --nushell-completion) \
|
||||
--zsh <($out/bin/foobar --zsh-completion)
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@
|
||||
|
||||
- [`homebox` 0.20.0](https://github.com/sysadminsmedia/homebox/releases/tag/v0.20.0) changed how assets are stored and hashed. It is recommended to back up your database before this update.
|
||||
|
||||
- `installShellCompletion`: now supports Nushell completion files
|
||||
|
||||
- New hardening flags, `strictflexarrays1` and `strictflexarrays3` were made available, corresponding to the gcc/clang options `-fstrict-flex-arrays=1` and `-fstrict-flex-arrays=3` respectively.
|
||||
|
||||
- `gramps` has been updated to 6.0.0
|
||||
|
||||
@@ -51,11 +51,11 @@ installManPage() {
|
||||
# installShellCompletion [--cmd <name>] ([--bash|--fish|--zsh] [--name <name>] <path>)...
|
||||
#
|
||||
# Each path is installed into the appropriate directory for shell completions for the given shell.
|
||||
# If one of `--bash`, `--fish`, or `--zsh` is given the path is assumed to belong to that shell.
|
||||
# Otherwise the file extension will be examined to pick a shell. If the shell is unknown a warning
|
||||
# will be logged and the command will return a non-zero status code after processing any remaining
|
||||
# paths. Any of the shell flags will affect all subsequent paths (unless another shell flag is
|
||||
# given).
|
||||
# If one of `--bash`, `--fish`, `--zsh`, or `--nushell` is given the path is assumed to belong to
|
||||
# that shell. Otherwise the file extension will be examined to pick a shell. If the shell is
|
||||
# unknown a warning will be logged and the command will return a non-zero status code after
|
||||
# processing any remaining paths. Any of the shell flags will affect all subsequent paths (unless
|
||||
# another shell flag is given).
|
||||
#
|
||||
# If the shell completion needs to be renamed before installing the optional `--name <name>` flag
|
||||
# may be given. Any name provided with this flag only applies to the next path.
|
||||
@@ -84,6 +84,7 @@ installManPage() {
|
||||
#
|
||||
# installShellCompletion --bash --name foobar.bash share/completions.bash
|
||||
# installShellCompletion --fish --name foobar.fish share/completions.fish
|
||||
# installShellCompletion --nushell --name foobar share/completions.nu
|
||||
# installShellCompletion --zsh --name _foobar share/completions.zsh
|
||||
#
|
||||
# Or to use shell newline escaping to split a single invocation across multiple lines:
|
||||
@@ -91,6 +92,7 @@ installManPage() {
|
||||
# installShellCompletion --cmd foobar \
|
||||
# --bash <($out/bin/foobar --bash-completion) \
|
||||
# --fish <($out/bin/foobar --fish-completion) \
|
||||
# --nushell <($out/bin/foobar --nushell-completion)
|
||||
# --zsh <($out/bin/foobar --zsh-completion)
|
||||
#
|
||||
# If any argument is `--` the remaining arguments will be treated as paths.
|
||||
@@ -100,7 +102,7 @@ installShellCompletion() {
|
||||
# Parse arguments
|
||||
if (( parseArgs )); then
|
||||
case "$arg" in
|
||||
--bash|--fish|--zsh)
|
||||
--bash|--fish|--zsh|--nushell)
|
||||
shell=${arg#--}
|
||||
continue;;
|
||||
--name)
|
||||
@@ -146,7 +148,7 @@ installShellCompletion() {
|
||||
elif [[ -p "$arg" ]]; then
|
||||
# this is a named fd or fifo
|
||||
if [[ -z "$curShell" ]]; then
|
||||
nixErrorLog "${FUNCNAME[0]}: named pipe requires one of --bash, --fish, or --zsh"
|
||||
nixErrorLog "${FUNCNAME[0]}: named pipe requires one of --bash, --fish, --zsh, or --nushell"
|
||||
return 1
|
||||
elif [[ -z "$name" && -z "$cmdname" ]]; then
|
||||
nixErrorLog "${FUNCNAME[0]}: named pipe requires one of --cmd or --name"
|
||||
@@ -161,6 +163,7 @@ installShellCompletion() {
|
||||
case "$argbase" in
|
||||
?*.bash) curShell=bash;;
|
||||
?*.fish) curShell=fish;;
|
||||
?*.nu) curShell=nushell;;
|
||||
?*.zsh) curShell=zsh;;
|
||||
*)
|
||||
if [[ "$argbase" = _* && "$argbase" != *.* ]]; then
|
||||
@@ -182,6 +185,7 @@ installShellCompletion() {
|
||||
elif [[ -n "$cmdname" ]]; then
|
||||
case "$curShell" in
|
||||
bash|fish) outName=$cmdname.$curShell;;
|
||||
nushell) outName=$cmdname.nu;;
|
||||
zsh) outName=_$cmdname;;
|
||||
*)
|
||||
# Our list of shells is out of sync with the flags we accept or extensions we detect.
|
||||
@@ -193,6 +197,7 @@ installShellCompletion() {
|
||||
case "$curShell" in
|
||||
bash) sharePath=bash-completion/completions;;
|
||||
fish) sharePath=fish/vendor_completions.d;;
|
||||
nushell) sharePath=nushell/vendor/autoload;;
|
||||
zsh)
|
||||
sharePath=zsh/site-functions
|
||||
# only apply automatic renaming if we didn't have a manual rename
|
||||
|
||||
@@ -14,11 +14,17 @@ runCommandLocal "install-shell-files--install-completion-cmd"
|
||||
echo bar > bar.zsh
|
||||
echo baz > baz.fish
|
||||
echo qux > qux.fish
|
||||
echo buzz > buzz.nu
|
||||
|
||||
installShellCompletion --cmd foobar --bash foo.bash --zsh bar.zsh --fish baz.fish --name qux qux.fish
|
||||
installShellCompletion \
|
||||
--cmd foobar --bash foo.bash \
|
||||
--zsh bar.zsh \
|
||||
--fish baz.fish --name qux qux.fish \
|
||||
--nushell --cmd buzzbar buzz.nu
|
||||
|
||||
cmp foo.bash $out/share/bash-completion/completions/foobar.bash
|
||||
cmp bar.zsh $out/share/zsh/site-functions/_foobar
|
||||
cmp baz.fish $out/share/fish/vendor_completions.d/foobar.fish
|
||||
cmp qux.fish $out/share/fish/vendor_completions.d/qux
|
||||
cmp buzz.nu $out/share/nushell/vendor/autoload/buzzbar.nu
|
||||
''
|
||||
|
||||
@@ -13,9 +13,11 @@ runCommandLocal "install-shell-files--install-completion-fifo"
|
||||
installShellCompletion \
|
||||
--bash --name foo.bash <(echo foo) \
|
||||
--zsh --name _foo <(echo bar) \
|
||||
--fish --name foo.fish <(echo baz)
|
||||
--fish --name foo.fish <(echo baz) \
|
||||
--nushell --name foo.nu <(echo bucks)
|
||||
|
||||
[[ $(<$out/share/bash-completion/completions/foo.bash) == foo ]] || { echo "foo.bash comparison failed"; exit 1; }
|
||||
[[ $(<$out/share/zsh/site-functions/_foo) == bar ]] || { echo "_foo comparison failed"; exit 1; }
|
||||
[[ $(<$out/share/fish/vendor_completions.d/foo.fish) == baz ]] || { echo "foo.fish comparison failed"; exit 1; }
|
||||
[[ $(<$out/share/nushell/vendor/autoload/foo.nu) == bucks ]] || { echo "foo.nu comparison failed"; exit 1; }
|
||||
''
|
||||
|
||||
@@ -13,10 +13,12 @@ runCommandLocal "install-shell-files--install-completion-inference"
|
||||
echo foo > foo.bash
|
||||
echo bar > bar.zsh
|
||||
echo baz > baz.fish
|
||||
echo buzz > buzz.nu
|
||||
|
||||
installShellCompletion foo.bash bar.zsh baz.fish
|
||||
installShellCompletion foo.bash bar.zsh baz.fish buzz.nu
|
||||
|
||||
cmp foo.bash $out/share/bash-completion/completions/foo.bash
|
||||
cmp bar.zsh $out/share/zsh/site-functions/_bar
|
||||
cmp baz.fish $out/share/fish/vendor_completions.d/baz.fish
|
||||
cmp buzz.nu $out/share/nushell/vendor/autoload/buzz.nu
|
||||
''
|
||||
|
||||
@@ -13,10 +13,16 @@ runCommandLocal "install-shell-files--install-completion-name"
|
||||
echo foo > foo
|
||||
echo bar > bar
|
||||
echo baz > baz
|
||||
echo bucks > bucks
|
||||
|
||||
installShellCompletion --bash --name foobar.bash foo --zsh --name _foobar bar --fish baz
|
||||
installShellCompletion \
|
||||
--bash --name foobar.bash foo \
|
||||
--zsh --name _foobar bar \
|
||||
--fish baz \
|
||||
--nushell --name foobar.nu bucks
|
||||
|
||||
cmp foo $out/share/bash-completion/completions/foobar.bash
|
||||
cmp bar $out/share/zsh/site-functions/_foobar
|
||||
cmp baz $out/share/fish/vendor_completions.d/baz
|
||||
cmp bucks $out/share/nushell/vendor/autoload/foobar.nu
|
||||
''
|
||||
|
||||
@@ -15,12 +15,18 @@ runCommandLocal "install-shell-files--install-completion"
|
||||
echo baz > baz
|
||||
echo qux > qux.zsh
|
||||
echo quux > quux
|
||||
echo quokka > quokka
|
||||
|
||||
installShellCompletion --bash foo bar --zsh baz qux.zsh --fish quux
|
||||
installShellCompletion \
|
||||
--bash foo bar \
|
||||
--zsh baz qux.zsh \
|
||||
--fish quux \
|
||||
--nushell quokka
|
||||
|
||||
cmp foo $out/share/bash-completion/completions/foo
|
||||
cmp bar $out/share/bash-completion/completions/bar
|
||||
cmp baz $out/share/zsh/site-functions/_baz
|
||||
cmp qux.zsh $out/share/zsh/site-functions/_qux
|
||||
cmp quux $out/share/fish/vendor_completions.d/quux
|
||||
cmp quokka $out/share/nushell/vendor/autoload/quokka
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user