Skip to content

Commit ec3b1e1

Browse files
authored
Merge branch 'nushell:main' into komorebi-completions
2 parents 12db2dc + f9b9636 commit ec3b1e1

File tree

5 files changed

+39
-33
lines changed

5 files changed

+39
-33
lines changed

custom-completions/git/git-completions.nu

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# nu-version: 0.102.0
2+
13
module git-completion-utils {
24
export const GIT_SKIPABLE_FLAGS = ['-v', '--version', '-h', '--help', '-p', '--paginate', '-P', '--no-pager', '--no-replace-objects', '--bare']
35

@@ -106,8 +108,8 @@ module git-completion-utils {
106108
let floating_remotes = $lines | filter { "\t" not-in $in and $in not-in $tracked_remotes }
107109
$floating_remotes | each {
108110
let v = $in | split row -n 2 '/' | get 1
109-
if $v != $current { [$v] } else []
110-
} | flatten
111+
if $v == $current { null } else $v
112+
}
111113
}
112114

113115
export def extract-mergable-sources [current: string]: list<string> -> list<record<value: string, description: string>> {
@@ -268,7 +270,7 @@ def "nu-complete git files" [] {
268270
def "nu-complete git built-in-refs" [] {
269271
[HEAD FETCH_HEAD ORIG_HEAD]
270272
}
271-
273+
272274
def "nu-complete git refs" [] {
273275
nu-complete git local branches
274276
| parse "{value}"

custom-completions/scoop/scoop-completions.nu

+6-14
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ def scoopAllApps [] {
4040
} else {
4141
[ $env.USERPROFILE, 'scoop', 'buckets' ] | path join
4242
}
43-
(ls -s $bucketsDir | get name) | each {|bucket| ls ([$bucketsDir, $bucket, 'bucket', '*.json'] | path join ) | get name | path basename | str substring ..-5} | flatten | uniq
43+
(ls -s $bucketsDir | get name) | each {|bucket| ls ([$bucketsDir, $bucket, 'bucket'] | path join ) | get name | path parse | where extension == json | get stem } | flatten | uniq
4444
}
4545

4646
# list of all apps that are not installed
4747
def scoopAvailableApps [] {
4848
let all = (scoopAllApps)
4949
let installed = (scoopInstalledApps)
5050

51-
$all | where not $it in $installed
51+
$all | where $it not-in $installed
5252
}
5353

5454
# list of all config options
@@ -117,7 +117,7 @@ def scoopCommands [] {
117117
[value, description];
118118
[
119119
# eg. scoop-help.ps1 -> help
120-
($command.name | path basename | str substring 6..-4),
120+
($command.name | path parse | get stem |str substring 6..),
121121
# second line is starts with '# Summary: '
122122
# eg. '# Summary: Install apps' -> 'Install apps'
123123
(open $command.name | lines | skip 1 | first | str substring 11..)
@@ -130,15 +130,7 @@ def scoopCommands [] {
130130
}
131131

132132
def scoopAliases [] {
133-
^powershell -nop -nol -c "(scoop alias list|ConvertTo-Json -Compress)"
134-
| decode
135-
| str trim
136-
| lines
137-
| last
138-
| to text
139-
| '[' + $in + ']'
140-
| from json
141-
| get Name
133+
scoop alias list | str trim | lines | slice 2.. | split column " " | get column1
142134
}
143135

144136
def batStyles [] {
@@ -658,7 +650,7 @@ export extern "scoop download" [
658650
################################################################
659651

660652
def scoopKnownBuckets [] {
661-
[ "main", "extras", "versions", "nirsoft", "php", "nerd-fonts", "nonportable", "java", "games" ]
653+
[ "main", "extras", "versions", "nirsoft", "php", "nerd-fonts", "nonportable", "java", "games", "sysinternals" ]
662654
}
663655

664656
def scoopInstalledBuckets [] {
@@ -676,7 +668,7 @@ def scoopAvailableBuckets [] {
676668
let known = (scoopKnownBuckets)
677669
let installed = (scoopInstalledBuckets)
678670

679-
$known | where not $it in $installed
671+
$known | where $it not-in $installed
680672
}
681673

682674
# Add, list or remove buckets.

custom-completions/ssh/ssh-completions.nu

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# nu-version: 0.102.0
2+
13
export extern "ssh" [
24
destination?: string@"nu-complete ssh-host"
35
-4 # Forces ssh to use IPv4 addresses only.
@@ -41,11 +43,12 @@ module ssh-completion-utils {
4143
# │ 4 │ │
4244
# ╰───┴──────────────────────────────╯
4345
let host = $in
44-
let name = $host | get 0 | str trim | split row -r '\s+' | get 1
46+
let $first_line = try { $host | first | str trim } catch { null }
4547
# Don't accept blocks like "Host *"
46-
if ('*' in $name) {
48+
if ($first_line | is-empty) or '*' in $first_line {
4749
null
4850
} else {
51+
let name = $first_line | split row -r '\s+' | get 1
4952
# May not contain hostname
5053
match ($host | slice 1.. | find -ir '^\s*Hostname\s') {
5154
[] => null,
@@ -68,7 +71,7 @@ module ssh-completion-utils {
6871
includes: $include_lines
6972
}
7073
}
71-
74+
7275
}
7376

7477

modules/fnm/fnm.nu

+17-9
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,25 @@ export-env {
2323
if not (which fnm | is-empty) {
2424
fnm-env | load-env
2525

26-
if (not ($env | default false __fnm_hooked | get __fnm_hooked)) {
27-
$env.__fnm_hooked = true
28-
$env.config = ($env | default {} config).config
29-
$env.config = ($env.config | default {} hooks)
30-
$env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
31-
$env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))
32-
$env.config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append { |before, after|
26+
$env.config = (
27+
$env.config?
28+
| default {}
29+
| upsert hooks { default {} }
30+
| upsert hooks.env_change { default {} }
31+
| upsert hooks.env_change.PWD { default [] }
32+
)
33+
let __fnm_hooked = (
34+
$env.config.hooks.env_change.PWD | any { try { get __fnm_hook } catch { false } }
35+
)
36+
if not $__fnm_hooked {
37+
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
38+
__fnm_hook: true,
39+
code: {|before, after|
3340
if ('FNM_DIR' in $env) and ([.nvmrc .node-version] | path exists | any { |it| $it }) {
34-
(^fnm use); (fnm-env | load-env)
41+
(^fnm use); (fnm-env | load-env)
42+
}
3543
}
36-
}))
44+
})
3745
}
3846
}
3947
}

sourced/cool-oneliners/find_in.nu

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Search terms in the specified files and/or folders based on the glob pattern provided.
22
def "find in" [
3-
glob: glob, # the glob expression
4-
...rest: any # terms to search
3+
glob: glob, # The glob expression
4+
--exclude (-e): list<string> # Patterns to exclude from the search: `find in` will not walk the inside of directories matching the excluded patterns.
5+
...rest: any # Terms to find
56
]: nothing -> table<path: string, line: int, data: string> {
6-
glob --no-dir $glob
7+
glob --exclude $exclude --no-dir $glob
78
| par-each {|e|
8-
open $e | lines | enumerate | rename line data |
9+
open --raw $e | lines | enumerate | rename line data |
910
find --columns [data] ...$rest |
1011
each {|match| {path: ($e | path relative-to $env.PWD), ...$match}}
1112
} | flatten

0 commit comments

Comments
 (0)