mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
Upgraded to 0.84 (#583)
`gig` for editing .gitignore export aliases of `docker.nu` implement `kdh` without helm-diff installed Co-authored-by: agent <agent@nuc>
This commit is contained in:
parent
f2e35e153c
commit
e5cf9b15ae
5 changed files with 62 additions and 39 deletions
|
@ -18,3 +18,9 @@ export-env {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# const path = "~/.nu"
|
||||||
|
# const if ($path| path expand | path exists) {
|
||||||
|
# source $path
|
||||||
|
# }
|
||||||
|
|
|
@ -419,25 +419,25 @@ export def "bud rm" [
|
||||||
buildah rm $id
|
buildah rm $id
|
||||||
}
|
}
|
||||||
|
|
||||||
alias dp = container-process-list
|
export alias dp = container-process-list
|
||||||
alias di = image-list
|
export alias di = image-list
|
||||||
alias dl = container-log
|
export alias dl = container-log
|
||||||
alias dln = container-log-namespace
|
export alias dln = container-log-namespace
|
||||||
alias da = container-attach
|
export alias da = container-attach
|
||||||
alias dcp = container-copy-file
|
export alias dcp = container-copy-file
|
||||||
alias dcr = container-remove
|
export alias dcr = container-remove
|
||||||
alias dci = container-inspect
|
export alias dci = container-inspect
|
||||||
alias dh = container-history
|
export alias dh = container-history
|
||||||
alias dsv = image-save
|
export alias dsv = image-save
|
||||||
alias dld = image-load
|
export alias dld = image-load
|
||||||
alias dsp = system-prune
|
export alias dsp = system-prune
|
||||||
alias dspall = system-prune-all
|
export alias dspall = system-prune-all
|
||||||
alias drmi = image-remove
|
export alias drmi = image-remove
|
||||||
alias dt = image-tag
|
export alias dt = image-tag
|
||||||
alias dps = image-push
|
export alias dps = image-push
|
||||||
alias dpl = image-pull
|
export alias dpl = image-pull
|
||||||
alias dvl = volume-list
|
export alias dvl = volume-list
|
||||||
alias dvc = volume-create
|
export alias dvc = volume-create
|
||||||
alias dvi = volume-inspect
|
export alias dvi = volume-inspect
|
||||||
alias dvr = volume-remove
|
export alias dvr = volume-remove
|
||||||
alias dr = container-create
|
export alias dr = container-create
|
||||||
|
|
|
@ -202,6 +202,11 @@ export def-env gn [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# edit .gitignore
|
||||||
|
export def gig [] {
|
||||||
|
e $"(git rev-parse --show-toplevel)/.gitignore"
|
||||||
|
}
|
||||||
|
|
||||||
# git pull, push and switch
|
# git pull, push and switch
|
||||||
export def gp [
|
export def gp [
|
||||||
branch?: string@"nu-complete git remote branches"
|
branch?: string@"nu-complete git remote branches"
|
||||||
|
@ -228,6 +233,7 @@ export def gp [
|
||||||
let remote = if ($remote|is-empty) { 'origin' } else { $remote }
|
let remote = if ($remote|is-empty) { 'origin' } else { $remote }
|
||||||
let lbs = (git branch | lines | each {|x| $x | str substring 2..})
|
let lbs = (git branch | lines | each {|x| $x | str substring 2..})
|
||||||
let rbs = (remote_braches | each {|x| $x.1})
|
let rbs = (remote_braches | each {|x| $x.1})
|
||||||
|
let prev = (_git_status).branch
|
||||||
if $branch in $rbs {
|
if $branch in $rbs {
|
||||||
if $branch in $lbs {
|
if $branch in $lbs {
|
||||||
let bmsg = '* both local and remote have the branch'
|
let bmsg = '* both local and remote have the branch'
|
||||||
|
@ -236,30 +242,21 @@ export def gp [
|
||||||
git branch -u $'($remote)/($branch)' $branch
|
git branch -u $'($remote)/($branch)' $branch
|
||||||
git push --force
|
git push --force
|
||||||
} else {
|
} else {
|
||||||
let prev = (_git_status).branch
|
|
||||||
print $'($bmsg), pull'
|
print $'($bmsg), pull'
|
||||||
if $prev != $branch {
|
if $prev != $branch {
|
||||||
print $'* switch to ($branch)'
|
print $'* switch to ($branch)'
|
||||||
git checkout $branch
|
git checkout $branch
|
||||||
}
|
}
|
||||||
git pull $m $a
|
git pull $m $a
|
||||||
if $back_to_prev {
|
|
||||||
git checkout $prev
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let prev = (_git_status).branch
|
|
||||||
print "* local doesn't have that branch, fetch"
|
print "* local doesn't have that branch, fetch"
|
||||||
git checkout -b $branch
|
git checkout -b $branch
|
||||||
git fetch $remote $branch
|
git fetch $remote $branch
|
||||||
git branch -u $'($remote)/($branch)' $branch
|
git branch -u $'($remote)/($branch)' $branch
|
||||||
git pull $m $a -v
|
git pull $m $a -v
|
||||||
if $back_to_prev {
|
|
||||||
git checkout $prev
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let prev = (_git_status).branch
|
|
||||||
let bmsg = "* remote doesn't have that branch"
|
let bmsg = "* remote doesn't have that branch"
|
||||||
let force = (sprb $force [--force])
|
let force = (sprb $force [--force])
|
||||||
if $branch in $lbs {
|
if $branch in $lbs {
|
||||||
|
@ -270,9 +267,10 @@ export def gp [
|
||||||
git checkout -b $branch
|
git checkout -b $branch
|
||||||
}
|
}
|
||||||
git push $force --set-upstream $remote $branch
|
git push $force --set-upstream $remote $branch
|
||||||
if $back_to_prev {
|
}
|
||||||
git checkout $prev
|
|
||||||
}
|
if $back_to_prev {
|
||||||
|
git checkout $prev
|
||||||
}
|
}
|
||||||
|
|
||||||
let s = (_git_status)
|
let s = (_git_status)
|
||||||
|
@ -300,7 +298,7 @@ export def ga [
|
||||||
if $delete {
|
if $delete {
|
||||||
let c = (sprb $cached [--cached])
|
let c = (sprb $cached [--cached])
|
||||||
let f = (sprb $force [--force])
|
let f = (sprb $force [--force])
|
||||||
git rm $c $f $file
|
git rm $c $f -r $file
|
||||||
} else if $restore {
|
} else if $restore {
|
||||||
let o = (spr [--source $source])
|
let o = (spr [--source $source])
|
||||||
let s = (sprb $staged [--staged])
|
let s = (sprb $staged [--staged])
|
||||||
|
@ -687,6 +685,6 @@ def git_main_branch [] {
|
||||||
| str trim
|
| str trim
|
||||||
| find --regex 'HEAD .*?[:: ].+'
|
| find --regex 'HEAD .*?[:: ].+'
|
||||||
| first
|
| first
|
||||||
| str replace 'HEAD .*?[:: ](.+)' '$1'
|
| str replace --regex 'HEAD .*?[:: ](.+)' '$1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,10 +225,28 @@ export def kah [
|
||||||
export def kdh [
|
export def kdh [
|
||||||
name: string@"nu-complete helm list"
|
name: string@"nu-complete helm list"
|
||||||
chart: string@"nu-complete helm charts"
|
chart: string@"nu-complete helm charts"
|
||||||
values: path
|
valuefile: path
|
||||||
|
--values (-v): any
|
||||||
--namespace (-n): string@"nu-complete kube ns"
|
--namespace (-n): string@"nu-complete kube ns"
|
||||||
|
--has-plugin (-h): bool
|
||||||
] {
|
] {
|
||||||
helm diff upgrade $name $chart -f $values (spr [-n $namespace])
|
if $has_plugin {
|
||||||
|
helm diff $name $chart -f $valuefile (spr [-n $namespace])
|
||||||
|
} else {
|
||||||
|
let update = $name in (
|
||||||
|
helm list (spr [-n $namespace]) --output json
|
||||||
|
| from json | get name
|
||||||
|
)
|
||||||
|
if not $update {
|
||||||
|
echo "new installation"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let values = if ($values | is-empty) { [] } else { [--set-json (record-to-set-json $values)] }
|
||||||
|
let target = $'/tmp/($chart | path basename).($name).out.yaml'
|
||||||
|
helm template --debug $name $chart -f $valuefile $values (spr [-n $namespace]) | save -f $target
|
||||||
|
kubectl diff -f $target
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# helm delete
|
# helm delete
|
||||||
|
|
|
@ -92,7 +92,8 @@ def time_segment [] {
|
||||||
def logtime [msg act] {
|
def logtime [msg act] {
|
||||||
let start = (date now)
|
let start = (date now)
|
||||||
let result = (do $act)
|
let result = (do $act)
|
||||||
let period = ($"((date now) - $start | into duration -c ns)" | str replace ' ' '')
|
# HACK: serialization
|
||||||
|
let period = ((date now) - $start | format duration ns | str replace ' ' '')
|
||||||
|
|
||||||
echo $'($start | format date '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
|
echo $'($start | format date '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
|
||||||
| save -a ~/.cache/nushell/power_time.log
|
| save -a ~/.cache/nushell/power_time.log
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue