upgrade to 0.86 (#640)

- upgrade to 0.86
- power.nu: new time's colorscheme `rainbow`

Co-authored-by: agent <agent@nuc>
This commit is contained in:
fj0r 2023-10-18 09:34:20 +08:00 committed by GitHub
parent 35669a39a9
commit 0a030b524b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 87 deletions

View File

@ -280,9 +280,9 @@ def host-path [path] {
# run
export def container-create [
--debug(-x): bool
--appimage: bool
--netadmin: bool
--debug(-x)
--appimage
--netadmin
--proxy: string@"nu-complete docker run proxy" # proxy
--ssh(-s): string@"nu-complete docker run sshkey" # specify ssh key
--sshuser: string=root # default root
@ -291,13 +291,13 @@ export def container-create [
--vols(-v): any # { host: container }
--ports(-p): any # { 8080: 80 }
--envs(-e): any # { FOO: BAR }
--daemon(-d): bool
--daemon(-d)
--attach(-a): string@"nu-complete docker container" # attach
--workdir(-w): string # workdir
--entrypoint: string # entrypoint
--dry-run: bool
--with-x: bool
--privileged(-P): bool
--dry-run
--with-x
--privileged(-P)
--namespace(-n): string@"nu-complete docker ns"
img: string@"nu-complete docker images" # image
...cmd # command args

View File

@ -1,6 +1,6 @@
def agree [
prompt
--default-not (-n): bool
--default-not (-n)
] {
let prompt = if ($prompt | str ends-with '!') {
$'(ansi red)($prompt)(ansi reset)'
@ -100,14 +100,14 @@ export def gs [] {
# git stash
export def gst [
--apply (-a): bool
--clear (-c): bool
--drop (-d): bool
--list (-l): bool
--pop (-p): bool
--show (-s): bool
--all (-A): bool
--include-untracked (-i): bool
--apply (-a)
--clear (-c)
--drop (-d)
--list (-l)
--pop (-p)
--show (-s)
--all (-A)
--include-untracked (-i)
] {
if $apply {
git stash apply
@ -131,7 +131,7 @@ export def gst [
# git log
export def gl [
commit?: string@"nu-complete git log"
--verbose(-v):bool
--verbose(-v)
--num(-n):int=32
] {
if ($commit|is-empty) {
@ -145,8 +145,8 @@ export def gl [
export def gb [
branch?: string@"nu-complete git branches"
remote?: string@"nu-complete git remote branches"
--delete (-d): bool
--no-merged (-n): bool
--delete (-d)
--no-merged (-n)
] {
let bs = (git branch | lines | each {|x| $x | str substring 2..})
if ($branch | is-empty) {
@ -178,8 +178,8 @@ export def gb [
export def-env gn [
repo?: string@"nu-complete git branches"
local?: path
--submodule (-s): bool # git submodule
--init (-i): bool # git init
--submodule (-s) # git submodule
--init (-i) # git init
] {
if $init {
if ($repo | is-empty) {
@ -211,13 +211,13 @@ export def gig [] {
export def gp [
branch?: string@"nu-complete git remote branches"
remote?: string@"nu-complete git remote branches"
--force (-f): bool # git push -f
--override: bool
--submodule (-s): bool # git submodule
--init (-i): bool # git init
--merge (-m): bool # git pull (no)--rebase
--autostash (-a): bool # git pull --autostash
--back-to-prev (-b): bool # back to branch
--force (-f) # git push -f
--override
--submodule (-s) # git submodule
--init (-i) # git init
--merge (-m) # git pull (no)--rebase
--autostash (-a) # git pull --autostash
--back-to-prev (-b) # back to branch
] {
if $submodule {
git submodule update
@ -284,15 +284,15 @@ export def gp [
# git add, rm and restore
export def ga [
file?: path
--all (-A): bool
--patch (-p): bool
--update (-u): bool
--verbose (-v): bool
--delete (-d): bool # git rm
--cached (-c): bool
--force (-f): bool
--restore (-r): bool # git restore
--staged (-s): bool
--all (-A)
--patch (-p)
--update (-u)
--verbose (-v)
--delete (-d) # git rm
--cached (-c)
--force (-f)
--restore (-r) # git restore
--staged (-s)
--source (-o): string
] {
if $delete {
@ -318,9 +318,9 @@ export def ga [
# git commit
export def gc [
message?: string
--all (-A): bool
--amend (-a): bool
--keep (-k): bool
--all (-A)
--amend (-a)
--keep (-k)
] {
let m = (spr [-m $message])
let a = (sprb $all [--all])
@ -332,9 +332,9 @@ export def gc [
# git diff
export def gd [
file?: path
--cached (-c): bool # cached
--word-diff (-w): bool # word-diff
--staged (-s): bool # staged
--cached (-c) # cached
--word-diff (-w) # word-diff
--staged (-s) # staged
] {
let w = (sprb $word_diff [--word-diff])
let c = (sprb $cached [--cached])
@ -345,10 +345,10 @@ export def gd [
# git merge
export def gm [
branch?: string@"nu-complete git branches"
--abort (-a): bool
--continue (-c): bool
--quit (-q): bool
--no-squash (-n): bool # git merge (no)--squash
--abort (-a)
--continue (-c)
--quit (-q)
--no-squash (-n) # git merge (no)--squash
] {
let x = if $no_squash { [] } else { [--squash] }
if ($branch | is-empty) {
@ -365,12 +365,12 @@ export def gm [
# TODO: --onto: (commit_id)
export def gr [
branch?: string@"nu-complete git branches"
--interactive (-i): bool
--interactive (-i)
--onto (-o): string
--abort (-a): bool
--continue (-c): bool
--skip (-s): bool
--quit (-q): bool
--abort (-a)
--continue (-c)
--skip (-s)
--quit (-q)
] {
if $abort {
git rebase --abort
@ -395,10 +395,10 @@ export def gr [
# git cherry-pick
export def gcp [
commit?: string@"nu-complete git log all"
--abort (-a): bool
--continue (-c): bool
--skip (-s): bool
--quit (-q): bool
--abort (-a)
--continue (-c)
--skip (-s)
--quit (-q)
] {
if $abort {
git cherry-pick --abort
@ -424,8 +424,8 @@ export def gcf [
# git reset
export def grs [
commit?: string@"nu-complete git log"
--hard (-h): bool
--clean (-c): bool
--hard (-h)
--clean (-c)
] {
let h = (sprb $hard [--hard])
let cm = (spr [$commit])
@ -440,11 +440,11 @@ export def grs [
export def grm [
remote?: string@"nu-complete git remotes"
uri?: string
--add (-a): bool
--rename (-r): bool
--delete (-d): bool
--update (-u): bool
--set (-s): bool
--add (-a)
--rename (-r)
--delete (-d)
--update (-u)
--set (-s)
] {
if ($remote | is-empty) {
git remote -v
@ -467,10 +467,10 @@ export def grm [
# git bisect
export def gbs [
--bad (-b): bool
--good (-g): bool
--reset (-r): bool
--start (-s): bool
--bad (-b)
--good (-g)
--reset (-r)
--start (-s)
] {
if $good {
git bisect good

View File

@ -78,7 +78,7 @@ export def normalize-column-names [ ] {
let cols = ($i | columns)
mut t = $i
for c in $cols {
$t = ($t | rename -c [$c ($c | str downcase | str replace ' ' '_')])
$t = ($t | rename -c {$c: ($c | str downcase | str replace ' ' '_')})
}
$t
}
@ -160,9 +160,9 @@ export def kk [p: path] {
export def kgh [
name?: string@"nu-complete helm list"
--namespace (-n): string@"nu-complete kube ns"
--manifest (-m): bool
--values(-v): bool
--all (-a): bool
--manifest (-m)
--values(-v)
--all (-a)
] {
if ($name | is-empty) {
let ns = if $all { [--all] } else { (spr [-n $namespace]) }
@ -228,7 +228,7 @@ export def kdh [
valuefile: path
--values (-v): any
--namespace (-n): string@"nu-complete kube ns"
--has-plugin (-h): bool
--has-plugin (-h)
] {
if $has_plugin {
helm diff $name $chart -f $valuefile (spr [-n $namespace])
@ -491,10 +491,10 @@ export def kg [
--namespace (-n): string@"nu-complete kube ns"
--jsonpath (-p): string@"nu-complete kube jsonpath"
--selector (-l): string
--verbose (-v): bool
--watch (-w): bool
--wide (-W): bool
--all (-a): bool
--verbose (-v)
--watch (-w)
--wide (-W)
--all (-a)
] {
let n = if $all {
[-A]
@ -584,7 +584,7 @@ export def kdel [
r: string@"nu-complete kube kind"
i: string@"nu-complete kube res"
--namespace (-n): string@"nu-complete kube ns"
--force(-f): bool
--force(-f)
] {
kubectl delete (spr [-n $namespace]) (sprb $force [--grace-period=0 --force]) $r $i
}
@ -619,7 +619,7 @@ export def kgp [
--namespace (-n): string@"nu-complete kube ns"
--jsonpath (-p): string@"nu-complete kube jsonpath"
--selector (-l): string
--all (-a): bool
--all (-a)
] {
if $all {
kg pods -a --wide
@ -700,8 +700,8 @@ export def kl [
pod: string@"nu-complete kube pods"
--namespace(-n): string@"nu-complete kube ns"
--container(-c): string@"nu-complete kube ctns"
--follow(-f): bool
--previous(-p): bool
--follow(-f)
--previous(-p)
] {
let n = (spr [-n $namespace])
let c = (spr [-c $container])
@ -882,7 +882,7 @@ export alias krsss = kubectl rollout status statefulset
# kubectl top pod
export def ktp [
--namespace (-n): string@"nu-complete kube ns"
--all(-a): bool
--all(-a)
] {
if $all {
kubectl top pod -A | from ssv -a | rename namespace name cpu mem

View File

@ -12,7 +12,7 @@ use power.nu
}
use power_utils.nu
power inject 0 1 {source: atuin, color: '#4C4B4A'}
power set time null { short: false }
power set time null { style: compact }
power init
```
or

View File

@ -79,10 +79,17 @@ def time_segment [] {
{|bg|
let config = $env.NU_POWER_CONFIG.time
let theme = $env.NU_POWER_THEME.time
let format = if $config.short {
$'($theme.fst)%y%m%d($theme.snd)%w($theme.fst)%H%M%S'
} else {
$'($theme.fst)%y-%m-%d[%w]%H:%M:%S'
let format = match $config.style {
"compact" => { $'($theme.fst)%y%m%d($theme.snd)%w($theme.fst)%H%M%S' }
"rainbow" => {
let fmt = [w y m d H M S]
let color = ['1;93m' '1;35m' '1;34m' '1;36m' '1;32m' '1;33m' '1;91m']
$fmt
| enumerate
| each { |x| $"(ansi -e ($color | get $x.index))%($x.item)" }
| str join
}
_ => { $'($theme.fst)%y-%m-%d[%w]%H:%M:%S' }
}
[$bg $"(date now | format date $format)"]
}
@ -596,7 +603,7 @@ export-env {
NU_POWER_CONFIG
{
time: {
short: true
style: null
}
}
)