1
0

zsh: container goodies

This commit is contained in:
Konstantin Demin 2024-07-12 15:41:17 +03:00
parent 9012696fea
commit bd1f46dec6
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0

View File

@ -7,7 +7,7 @@ alias bud='buildah bud --network=host -f '
function { function {
local i local i
for i ( run images ps inspect logs ) ; do for i ( run images ps top inspect logs ) ; do
alias "pod-$i"="podman $i " alias "pod-$i"="podman $i "
done done
} }
@ -20,6 +20,7 @@ z-podman() {
run ) shift ; z-pod-run "$@" ;; run ) shift ; z-pod-run "$@" ;;
images ) shift ; z-pod-images "$@" ;; images ) shift ; z-pod-images "$@" ;;
ps ) shift ; z-pod-ps "$@" ;; ps ) shift ; z-pod-ps "$@" ;;
top ) shift ; z-pod-top "$@" ;;
* ) z-pod "$@" ;; * ) z-pod "$@" ;;
esac esac
} }
@ -31,24 +32,40 @@ z-pod-run() {
z-pod-images() { z-pod-images() {
local have_flags=0 local have_flags=0
case "$1" in case "$1" in
-* ) have_flags=1 ;; -* ) have_flags=1 ; break ;;
esac esac
if [ ${have_flags} = 1 ] ; then if [ ${have_flags} = 1 ] ; then
z-pod images "$@" z-pod images "$@"
else return $?
z-pod images --format 'table {{.ID}} {{.Repository}}:{{.Tag}} {{.Size}} {{.Created}} |{{.CreatedAt}}' "$@"
fi fi
z-pod images --format 'table {{.ID}} {{.Repository}}:{{.Tag}} {{.Size}} {{.Created}} |{{.CreatedAt}}' "$@"
} }
z-pod-ps() { z-pod-ps() {
local have_flags=0 local have_flags=0
case "$1" in case "$1" in
-* ) have_flags=1 ;; -* ) have_flags=1 ; break ;;
esac esac
if [ ${have_flags} = 1 ] ; then if [ ${have_flags} = 1 ] ; then
z-pod ps "$@" z-pod ps "$@"
return $?
fi
z-pod ps -a --sort names --format 'table {{.ID}} {{.Names}} {{.Image}} {{.CreatedHuman}} {{.Status}}' "$@"
}
z-pod-top() {
local have_flags=0
case "$1" in
-* ) have_flags=1 ; break ;;
esac
if [ ${have_flags} = 1 ] ; then
z-pod top "$@"
return $?
fi
if [ $# -eq 1 ] ; then
z-pod top "$1" 'pid,ppid,user,args,pcpu,time,stime,etime,state,nice,rss,vsz'
else else
z-pod ps -a --sort names --format 'table {{.ID}} {{.Names}} {{.Image}} {{.CreatedHuman}} {{.Status}}' "$@" z-pod top "$@"
fi fi
} }