Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ssh-completions when there's no includes #1065

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions custom-completions/ssh/ssh-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def "nu-complete ssh-host" [] {
$r.includes = $r.includes | each {|f| $folder | path join $f }
$r
} | reduce {|it| merge deep $it --strategy=append }
let hosts = $first_result.hosts

let $includes: list<string> = $first_result.includes | each {|f|
if '*' in $f {
glob $f
Expand All @@ -99,8 +99,11 @@ def "nu-complete ssh-host" [] {
} | flatten

# Process include files
let second_result = $includes | par-each {|p| $p | open --raw | process } | reduce {|it| merge deep $it --strategy=append }
# We don't further process "Include" lines in these secondary files.
let hosts = $hosts ++ $second_result.hosts
let included_hosts = (if ($includes | is-empty) { [] } else {
let second_result = $includes | par-each {|p| $p | open --raw | process } | reduce {|it| merge deep $it --strategy=append }
$second_result.hosts
})

let hosts = $first_result.hosts ++ $included_hosts
$hosts | each { {value: $in.name, description: $in.addr } }
}