mirror of
https://github.com/nushell/nushell.git
synced 2025-05-30 06:39:33 +02:00
Put completions in their own module (#4880)
This commit is contained in:
parent
bd5778fa24
commit
d5f23ab592
@ -54,20 +54,21 @@ let-env NU_PLUGIN_DIRS = [
|
||||
($nu.config-path | path dirname | path join 'plugins')
|
||||
]
|
||||
|
||||
# Custom completions for external commands (those outside of Nushell)
|
||||
# Each completions has two parts: the form of the external command, including its flags and parameters
|
||||
# and a helper command that knows how to complete values for those flags and parameters
|
||||
#
|
||||
# This is a simplified version of completions for git branches and git remotes
|
||||
def "nu-complete git branches" [] {
|
||||
module completions {
|
||||
# Custom completions for external commands (those outside of Nushell)
|
||||
# Each completions has two parts: the form of the external command, including its flags and parameters
|
||||
# and a helper command that knows how to complete values for those flags and parameters
|
||||
#
|
||||
# This is a simplified version of completions for git branches and git remotes
|
||||
def "nu-complete git branches" [] {
|
||||
^git branch | lines | each { |line| $line | str find-replace '\* ' '' | str trim }
|
||||
}
|
||||
}
|
||||
|
||||
def "nu-complete git remotes" [] {
|
||||
def "nu-complete git remotes" [] {
|
||||
^git remote | lines | each { |line| $line | str trim }
|
||||
}
|
||||
}
|
||||
|
||||
extern "git checkout" [
|
||||
export extern "git checkout" [
|
||||
branch?: string@"nu-complete git branches" # name of the branch to checkout
|
||||
-b: string # create and checkout a new branch
|
||||
-B: string # create/reset and checkout a branch
|
||||
@ -90,9 +91,9 @@ extern "git checkout" [
|
||||
--patch(-p) # select hunks interactively
|
||||
--ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only
|
||||
--pathspec-from-file: string # read pathspec from file
|
||||
]
|
||||
]
|
||||
|
||||
extern "git push" [
|
||||
export extern "git push" [
|
||||
remote?: string@"nu-complete git remotes", # the name of the remote
|
||||
refspec?: string@"nu-complete git branches"# the branch / refspec
|
||||
--verbose(-v) # be more verbose
|
||||
@ -120,7 +121,11 @@ extern "git push" [
|
||||
--push-option(-o): string # option to transmit
|
||||
--ipv4(-4) # use IPv4 addresses only
|
||||
--ipv6(-6) # use IPv6 addresses only
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
# Get just the extern definitions without the custom completion commands
|
||||
use completions *
|
||||
|
||||
# for more information on themes see
|
||||
# https://github.com/nushell/nushell/blob/main/docs/How_To_Coloring_and_Theming.md
|
||||
|
Loading…
x
Reference in New Issue
Block a user