@@ -231,10 +231,11 @@ const short_status_descriptions = {
231231 "UU" : " Both modified (in merge conflict)"
232232}
233233
234- def "nu-complete git files" [] {
234+ def "nu-complete git files" [path ?: string ] {
235235 let relevant_statuses = [" ?" ," .M" , " MM" , " MD" , " .D" , " UU" ]
236- ^ git status - uall -- porcelain=2
236+ ^ git status - uall -- porcelain=2 ( if ( $path | describe ) == ' string ' and ( $path | str length ) != 0 { $" ( $path ) " } else { " . " } )
237237 | lines
238+ | first 300 # limit the number of data for performance
238239 | each { |$it |
239240 if $it starts-with " 1 " {
240241 $it | parse -- regex " 1 (?P<short_status>\\ S+) (?:\\ S+\\ s?){6} (?P<value>\\ S+)"
@@ -261,17 +262,22 @@ def "nu-complete git refs" [] {
261262 nu-complete git local branches
262263 | parse " {value}"
263264 | insert description Branch
265+ | append (nu-complete git remotes | parse ' {value}' | insert description ' Remote branch' )
264266 | append (nu-complete git tags | parse " {value}" | insert description Tag )
265267 | append (nu-complete git built-in-refs )
266268}
267269
268270def "nu-complete git files-or-refs" [] {
269- nu-complete git local branches
270- | parse " {value}"
271- | insert description Branch
272- | append (nu-complete git files | where description == " Modified" | select value )
273- | append (nu-complete git tags | parse " {value}" | insert description Tag )
274- | append (nu-complete git built-in-refs )
271+ {
272+ options : { sort : false },
273+ completions : (
274+ nu-complete git files | where description == " Modified" | select value description
275+ | append (nu-complete git local branches | parse ' {value}' | insert description ' Local branch' )
276+ | append (nu-complete git built-in-refs | parse ' {value}' | insert description ' Built-in Refs' )
277+ | append (nu-complete git tags | parse ' {value}' | insert description Tag )
278+ | append (nu-complete git remotes | get ' value' | parse ' {value}' | insert description ' Remote branch' )
279+ )
280+ }
275281}
276282
277283def "nu-complete git aliases" [] {
0 commit comments