Skip to content

Commit 8b40551

Browse files
authored
fix(scoop-completions): correct substring indices to properly trim .ps1 extension (#1056)
here will be an additional dot following each subcommand. ![image](https://github.com/user-attachments/assets/af72e9fa-b92e-4387-b0d8-ba4e84c5f2cf)
1 parent 1da73cf commit 8b40551

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

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.

0 commit comments

Comments
 (0)