just do everything i guess
This commit is contained in:
parent
1e7b7d1614
commit
cadc5f98d4
5 changed files with 274 additions and 21 deletions
30
flake.nix
30
flake.nix
|
|
@ -60,8 +60,7 @@
|
|||
let inshellah_complete = { |spans|
|
||||
let completions = (^inshellah complete ...$spans) | from json
|
||||
# dynamic completions
|
||||
let additional = if ($completions == null and
|
||||
($spans | length) > 0) {
|
||||
let additional = if ($completions == null and ($spans | length) > 0) {
|
||||
match $spans.0 {
|
||||
"nix" => {
|
||||
$env.NIX_GET_COMPLETIONS = ($spans | length) - 1
|
||||
|
|
@ -73,30 +72,37 @@
|
|||
$env.NIX_ALLOW_BROKEN = 1
|
||||
$nix_output | par-each { |e|
|
||||
try {
|
||||
{ value: $e, description: (^nix eval --impure $e --apply "f: f.meta.description" err> /dev/null) }
|
||||
} catch {} finally {
|
||||
{ value: $e, description: (^nix eval --impure $e --apply "f: f.meta.description" err> /dev/null) }
|
||||
} catch {
|
||||
{ value: $e, description: "" }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$nix_output | each { |e| { value: $e, description: "" } }
|
||||
$nix_output | each { |e|
|
||||
{ value: $e, description: "" }
|
||||
}
|
||||
}
|
||||
$entries
|
||||
}
|
||||
"systemctl" => {
|
||||
if ($spans | length) < 2 { null } else {
|
||||
if ($spans | length) < 3 { null } else {
|
||||
let kw = $spans | last
|
||||
^systemctl list-units --all --no-pager --plain --full $"($kw)*"
|
||||
| detect columns
|
||||
| drop 7
|
||||
| headers
|
||||
| each { |r| {value: $r.UNIT, description: ($r.DESCRIPTION | default "")} }
|
||||
let scope = if ("--user" in $spans) { [--user] } else { [] }
|
||||
^systemctl ...$scope list-units --all --no-pager --plain --full --no-legend $"($kw)*"
|
||||
| lines
|
||||
| each { |l|
|
||||
let parsed = $l | parse -r '(?P<unit>\S+)\s+\S+\s+\S+\s+\S+\s+(?P<desc>.*)'
|
||||
if ($parsed | length) > 0 {
|
||||
{value: $parsed.0.unit, description: ($parsed.0.desc | str trim)}
|
||||
}
|
||||
} | compact
|
||||
}
|
||||
}
|
||||
_ => { null }
|
||||
}
|
||||
} else { null }
|
||||
$completions | append $additional
|
||||
let result = ($completions | default []) | append ($additional | default []) | compact
|
||||
if ($result | is-empty) { null } else { $result }
|
||||
}
|
||||
$env.config.completions.external = {enable: true, max_results: 200, completer: $inshellah_complete}
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue