1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-30 03:27:45 +00:00

Use carapace properly

This commit is contained in:
RGBCube 2023-12-13 00:39:46 +03:00
parent a20cab18bf
commit 8aad332ab9
No known key found for this signature in database
2 changed files with 2 additions and 47 deletions

View file

@ -124,49 +124,7 @@ $env.config.completions = {
partial: true
quick: true
external: {
enable: true
max_results: 100
completer: {|tokens: list<string>|
let expanded_alias = scope aliases | where name == $tokens.0 | get --ignore-errors expansion.0
let tokens = if $expanded_alias != null {
$expanded_alias | split row " " | append ($tokens | skip 1)
} else {
$tokens
}
let command = $tokens.0 | str trim --left --char "^"
let completions = carapace $command nushell $tokens | from json | default []
if ($completions | is-empty) {
let path = $tokens | last
ls $"($path)*" | each {|it|
let choice = if ($path | str ends-with "/") {
$path | path join ($it.name | path basename)
} else {
$path | path dirname | path join ($it.name | path basename)
}
let choice = if ($it.type == "dir") and (not ($choice | str ends-with "/")) {
$"($choice)/"
} else {
$choice
}
if ($choice | str contains " ") {
$"`($choice)`"
} else {
$choice
}
}
} else if ($completions | where value =~ "^.*ERR$" | is-empty) {
$completions
} else {
null
}
}
}
}

View file

@ -1,10 +1,11 @@
{ config, ulib, pkgs, upkgs, theme, ... }: with ulib; merge3
{ config, ulib, pkgs, upkgs, theme, ... }: with ulib; merge
(systemConfiguration {
users.defaultUserShell = pkgs.nushell;
})
(homeConfiguration {
programs.carapace = enabled {};
programs.starship = enabled {};
programs.nushell = enabled {
@ -31,7 +32,3 @@
};
};
})
(homePackages (with pkgs; [
carapace
]))