1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Experimental multi-taskrunner support for jx (npm for example) (#492)

* Experimental multi-task runner support for `jx` (npm for example)

- Remove `nu-complete` export for debugging.
- Formatting `nu-complete just recipes`

* Use `jx` to override `j`.

Only for `just`, it only adds a prefix when completing, and does not break the original workflow

* `nu-complete just recipes` append empty string

When all the completions are `just xxx`, there is only `just` in the menu, press `C-w` to delete backwards to work.

* kgp takes `-o default` by default

move just to just/just.nu

* `gp` uses `git pull` instead of `git fetch` by default, and there is only one request when `push` is not needed

* add kgpw for `kubectl get pods --watch`

adjust `gm` to make it clearer

* remove just.nu

---------

Co-authored-by: agent <agent@nuc>
This commit is contained in:
fj0r 2023-05-17 09:07:08 +08:00 committed by GitHub
parent f86a060c10
commit b6ecfe3680
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 14 deletions

View file

@ -122,13 +122,11 @@ export def gp [
git fetch $remote $branch
}
} else {
git fetch
let r = if $rebase { [--rebase] } else { [] }
let a = if $autostash { [--autostash] } else { [] }
git pull $r $a -v
let s = (_git_status)
if $s.behind > 0 {
let r = if $rebase { [--rebase] } else { [] }
let a = if $autostash { [--autostash] } else { [] }
git pull $r $a -v
} else if $s.ahead > 0 {
if $s.ahead > 0 {
git push
}
}
@ -221,10 +219,12 @@ export def gm [
git rebase $branch
}
}
} else if ($branch | is-empty) {
git merge $"origin/(git_main_branch)"
} else {
git merge $branch
if ($branch | is-empty) {
git merge $"origin/(git_main_branch)"
} else {
git merge $branch
}
}
}
@ -484,7 +484,7 @@ def "nu-complete git log" [] {
| each {|x| $x | update value $"($x.value)"}
}
export def "nu-complete git branches" [] {
def "nu-complete git branches" [] {
git branch
| lines
| filter {|x| not ($x | str starts-with '*')}

View file

@ -210,7 +210,7 @@ def "nu-complete kube res via name" [context: string, offset: int] {
kubectl get $ns $kind | from ssv -a | get NAME
}
export def "nu-complete kube jsonpath" [context: string] {
def "nu-complete kube jsonpath" [context: string] {
let ctx = ($context | parse cmd)
let kind = ($ctx | get args.1)
let res = ($ctx | get args.2)
@ -257,6 +257,7 @@ export def kg [
--selector (-l): string
--verbose (-v): bool
--watch (-w): bool
--wide (-W): bool
--all (-A): bool
] {
let n = if $all {
@ -269,6 +270,7 @@ export def kg [
let r = if ($r | is-empty) { [] } else { [$r] }
let l = if ($selector | is-empty) { [] } else { [-l $selector] }
if ($jsonpath | is-empty) {
let wide = if $wide { [-o wide] } else { [] }
if ($verbose) {
kubectl get -o json $n $k $r | from json | get items
| each {|x|
@ -283,9 +285,9 @@ export def kg [
}
}
} else if $watch {
kubectl get $n $k $r --watch
kubectl get $n $k $r $wide --watch
} else {
kubectl get $n $k $r | from ssv -a
kubectl get $n $k $r $wide | from ssv -a
}
} else {
kubectl get $n $k $r $"--output=jsonpath={($jsonpath)}" | from json
@ -375,7 +377,15 @@ export def kgp [
--jsonpath (-p): string@"nu-complete kube jsonpath"
--selector (-l): string
] {
kg pods -n $namespace -p $jsonpath -l $selector $r
kg pods -n $namespace -p $jsonpath -l $selector --wide $r
}
export def kgpw [
r?: string@"nu-complete kube res via name"
--namespace (-n): string@"nu-complete kube ns"
--selector (-l): string
] {
kg pods -n $namespace -w -l $selector --wide $r
}
# kubectl edit pod