mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
✨ add worktree completions (#933)
you can now `git worktree remove <tab>` for autocompletions  and show the branches _after_ the path in `git worktree add ./my-path <tab>` 
This commit is contained in:
parent
7b2ec35cf2
commit
0cba7933f2
1 changed files with 22 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
def "nu-complete git available upstream" [] {
|
def "nu-complete git available upstream" [] {
|
||||||
^git branch -a | lines | each { |line| $line | str replace '\* ' "" | str trim }
|
^git branch -a | lines | each { |line| $line | str replace '* ' "" | str trim }
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete git remotes" [] {
|
def "nu-complete git remotes" [] {
|
||||||
|
@ -126,15 +126,20 @@ def "nu-complete git built-in-refs" [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete git refs" [] {
|
def "nu-complete git refs" [] {
|
||||||
nu-complete git switch
|
nu-complete git switchable branches
|
||||||
| update description Branch
|
| parse "{value}"
|
||||||
| append (nu-complete git tags | update description Tag)
|
| insert description Branch
|
||||||
| append (nu-complete git built-in-refs | wrap value | insert description Ref)
|
| append (nu-complete git tags | parse "{value}" | insert description Tag)
|
||||||
|
| append (nu-complete git built-in-refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete git files-or-refs" [] {
|
def "nu-complete git files-or-refs" [] {
|
||||||
nu-complete git refs
|
nu-complete git switchable branches
|
||||||
| prepend (nu-complete git files | where description == "Modified")
|
| parse "{value}"
|
||||||
|
| insert description Branch
|
||||||
|
| append (nu-complete git files | where description == "Modified" | select value)
|
||||||
|
| append (nu-complete git tags | parse "{value}" | insert description Tag)
|
||||||
|
| append (nu-complete git built-in-refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
def "nu-complete git subcommands" [] {
|
def "nu-complete git subcommands" [] {
|
||||||
|
@ -584,6 +589,8 @@ export extern "git worktree" [
|
||||||
|
|
||||||
# create a new working tree
|
# create a new working tree
|
||||||
export extern "git worktree add" [
|
export extern "git worktree add" [
|
||||||
|
path: path # directory to clone the branch
|
||||||
|
branch: string@"nu-complete git available upstream" # Branch to clone
|
||||||
--help(-h) # display the help message for this command
|
--help(-h) # display the help message for this command
|
||||||
--force(-f) # checkout <branch> even if already checked out in other worktree
|
--force(-f) # checkout <branch> even if already checked out in other worktree
|
||||||
-b # create a new branch
|
-b # create a new branch
|
||||||
|
@ -608,8 +615,14 @@ export extern "git worktree list" [
|
||||||
...args
|
...args
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def "nu-complete worktree list" [] {
|
||||||
|
^git worktree list | to text | parse --regex '(?P<value>\S+)\s+(?P<commit>\w+)\s+(?P<description>\S.*)'
|
||||||
|
}
|
||||||
|
|
||||||
# prevent a working tree from being pruned
|
# prevent a working tree from being pruned
|
||||||
export extern "git worktree lock" [
|
export extern "git worktree lock" [
|
||||||
|
worktree: string@"nu-complete worktree list"
|
||||||
|
--reason: string # reason because the tree is locked
|
||||||
--help(-h) # display the help message for this command
|
--help(-h) # display the help message for this command
|
||||||
--reason # reason for locking
|
--reason # reason for locking
|
||||||
...args
|
...args
|
||||||
|
@ -633,13 +646,14 @@ export extern "git worktree prune" [
|
||||||
|
|
||||||
# remove a working tree
|
# remove a working tree
|
||||||
export extern "git worktree remove" [
|
export extern "git worktree remove" [
|
||||||
|
worktree: string@"nu-complete worktree list"
|
||||||
--help(-h) # display the help message for this command
|
--help(-h) # display the help message for this command
|
||||||
--force(-f) # force removal even if worktree is dirty or locked
|
--force(-f) # force removal even if worktree is dirty or locked
|
||||||
...args
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# allow working tree to be pruned, moved or deleted
|
# allow working tree to be pruned, moved or deleted
|
||||||
export extern "git worktree unlock" [
|
export extern "git worktree unlock" [
|
||||||
|
worktree: string@"nu-complete worktree list"
|
||||||
...args
|
...args
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue