From c58ca9c446d5808a333aa6132f6c033a1f4e88ce Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Sun, 27 Mar 2022 18:08:33 +0100 Subject: [PATCH] add git switch completion (#190) --- custom-completions/git/git-completions.nu | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/custom-completions/git/git-completions.nu b/custom-completions/git/git-completions.nu index dadf4ab..bbb0503 100644 --- a/custom-completions/git/git-completions.nu +++ b/custom-completions/git/git-completions.nu @@ -8,6 +8,10 @@ def "nu-complete git remotes" [] { ^git remote | lines | each { |line| $line | str trim } } +def "nu-complete git log" [] { + ^git log --pretty=%h | lines | each { |line| $line | str trim } +} + # Top leve git command # extern "git" [ @@ -69,3 +73,24 @@ extern "git push" [ --ipv4(-4) # use IPv4 addresses only --ipv6(-6) # use IPv6 addresses only ] + +# Switch between branches and commits +export extern "git switch" [ + switch?: string@"nu-complete git branches" # name of branch to switch to + --create(-c): string # create a new branch + --force-create(-C): string # forces creation of new branch, if it exists then the existing branch will be reset to starting point + --detach(-d): string@"nu-complete git log" # switch to a commit in a detatched state + --guess # if there is no local branch which matches then name but there is a remote one then this is checked out + --no-guess # do not attempt to match remote branch names + --force(-f) # alias for --discard-changes + --merge(-m) # attempts to merge changes when switching branches if there are local changes + --quiet(-q) # suppress feedback messages + --progress # report progress status + --no-progress # do not report progress + --track(-t) # set "upstream" configuration + --no-track # do not set "upstream" configuration + --orphan: string # create a new orphaned branch + --ignore-other-worktrees # switch even if the ref is held by another worktree + --recurse-submodules # update the contents of sub-modules + --no-recurse-submodules # do not update the contents of sub-modules +]