mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37: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
|
@ -419,25 +419,25 @@ export def "bud rm" [
|
|||
buildah rm $id
|
||||
}
|
||||
|
||||
alias dp = container-process-list
|
||||
alias di = image-list
|
||||
alias dl = container-log
|
||||
alias dln = container-log-namespace
|
||||
alias da = container-attach
|
||||
alias dcp = container-copy-file
|
||||
alias dcr = container-remove
|
||||
alias dci = container-inspect
|
||||
alias dh = container-history
|
||||
alias dsv = image-save
|
||||
alias dld = image-load
|
||||
alias dsp = system-prune
|
||||
alias dspall = system-prune-all
|
||||
alias drmi = image-remove
|
||||
alias dt = image-tag
|
||||
alias dps = image-push
|
||||
alias dpl = image-pull
|
||||
alias dvl = volume-list
|
||||
alias dvc = volume-create
|
||||
alias dvi = volume-inspect
|
||||
alias dvr = volume-remove
|
||||
alias dr = container-create
|
||||
export alias dp = container-process-list
|
||||
export alias di = image-list
|
||||
export alias dl = container-log
|
||||
export alias dln = container-log-namespace
|
||||
export alias da = container-attach
|
||||
export alias dcp = container-copy-file
|
||||
export alias dcr = container-remove
|
||||
export alias dci = container-inspect
|
||||
export alias dh = container-history
|
||||
export alias dsv = image-save
|
||||
export alias dld = image-load
|
||||
export alias dsp = system-prune
|
||||
export alias dspall = system-prune-all
|
||||
export alias drmi = image-remove
|
||||
export alias dt = image-tag
|
||||
export alias dps = image-push
|
||||
export alias dpl = image-pull
|
||||
export alias dvl = volume-list
|
||||
export alias dvc = volume-create
|
||||
export alias dvi = volume-inspect
|
||||
export alias dvr = volume-remove
|
||||
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
|
||||
export def gp [
|
||||
branch?: string@"nu-complete git remote branches"
|
||||
|
@ -228,6 +233,7 @@ export def gp [
|
|||
let remote = if ($remote|is-empty) { 'origin' } else { $remote }
|
||||
let lbs = (git branch | lines | each {|x| $x | str substring 2..})
|
||||
let rbs = (remote_braches | each {|x| $x.1})
|
||||
let prev = (_git_status).branch
|
||||
if $branch in $rbs {
|
||||
if $branch in $lbs {
|
||||
let bmsg = '* both local and remote have the branch'
|
||||
|
@ -236,30 +242,21 @@ export def gp [
|
|||
git branch -u $'($remote)/($branch)' $branch
|
||||
git push --force
|
||||
} else {
|
||||
let prev = (_git_status).branch
|
||||
print $'($bmsg), pull'
|
||||
if $prev != $branch {
|
||||
print $'* switch to ($branch)'
|
||||
git checkout $branch
|
||||
}
|
||||
git pull $m $a
|
||||
if $back_to_prev {
|
||||
git checkout $prev
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let prev = (_git_status).branch
|
||||
print "* local doesn't have that branch, fetch"
|
||||
git checkout -b $branch
|
||||
git fetch $remote $branch
|
||||
git branch -u $'($remote)/($branch)' $branch
|
||||
git pull $m $a -v
|
||||
if $back_to_prev {
|
||||
git checkout $prev
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let prev = (_git_status).branch
|
||||
let bmsg = "* remote doesn't have that branch"
|
||||
let force = (sprb $force [--force])
|
||||
if $branch in $lbs {
|
||||
|
@ -270,9 +267,10 @@ export def gp [
|
|||
git checkout -b $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)
|
||||
|
@ -300,7 +298,7 @@ export def ga [
|
|||
if $delete {
|
||||
let c = (sprb $cached [--cached])
|
||||
let f = (sprb $force [--force])
|
||||
git rm $c $f $file
|
||||
git rm $c $f -r $file
|
||||
} else if $restore {
|
||||
let o = (spr [--source $source])
|
||||
let s = (sprb $staged [--staged])
|
||||
|
@ -687,6 +685,6 @@ def git_main_branch [] {
|
|||
| str trim
|
||||
| find --regex 'HEAD .*?[:: ].+'
|
||||
| first
|
||||
| str replace 'HEAD .*?[:: ](.+)' '$1'
|
||||
| str replace --regex 'HEAD .*?[:: ](.+)' '$1'
|
||||
}
|
||||
|
||||
|
|
|
@ -225,10 +225,28 @@ export def kah [
|
|||
export def kdh [
|
||||
name: string@"nu-complete helm list"
|
||||
chart: string@"nu-complete helm charts"
|
||||
values: path
|
||||
valuefile: path
|
||||
--values (-v): any
|
||||
--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
|
||||
|
|
|
@ -92,7 +92,8 @@ def time_segment [] {
|
|||
def logtime [msg act] {
|
||||
let start = (date now)
|
||||
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)'
|
||||
| save -a ~/.cache/nushell/power_time.log
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue