Moved dex to seperate file
This commit is contained in:
59
systems/modules/home/programs/zsh/functions/dex.zsh
Normal file
59
systems/modules/home/programs/zsh/functions/dex.zsh
Normal file
@@ -0,0 +1,59 @@
|
||||
dex() {
|
||||
clear
|
||||
local container
|
||||
|
||||
container=$(
|
||||
docker ps --format '{{.Names}}\t{{.Image}}\t{{.Status}}' |
|
||||
sort |
|
||||
fzf \
|
||||
--delimiter=$'\t' \
|
||||
--with-nth=1,2,3 \
|
||||
--header=$'Ctrl-I: Inspect | Ctrl-L: Logs | Ctrl-R: Refresh | ?: Toggle Preview\n\nNAME\tIMAGE\tSTATUS' \
|
||||
--tabstop=4 \
|
||||
--height=90% \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--info=inline-right \
|
||||
--prompt='🐳 Container > ' \
|
||||
--pointer='▶' \
|
||||
--marker='✓' \
|
||||
--preview 'docker logs -f --tail=50 {1} 2>&1' \
|
||||
--preview-label=' Logs ' \
|
||||
--preview-window='right,65%,follow,border-left,wrap' \
|
||||
--bind 'ctrl-r:reload(docker ps --format "{{.Names}}\t{{.Image}}\t{{.Status}}" | sort)' \
|
||||
--bind 'ctrl-u:preview-half-page-up' \
|
||||
--bind 'ctrl-d:preview-half-page-down' \
|
||||
--bind '?:toggle-preview' \
|
||||
--bind 'ctrl-l:change-preview(docker logs -f --tail=50 {1} 2>&1)+change-preview-label(Logs)' \
|
||||
--bind 'ctrl-i:change-preview(
|
||||
docker inspect --format "
|
||||
Name: {{.Name}}
|
||||
Image: {{.Config.Image}}
|
||||
Status: {{.State.Status}}
|
||||
Running: {{.State.Running}}
|
||||
Started: {{.State.StartedAt}}
|
||||
Finished: {{.State.FinishedAt}}
|
||||
PID: {{.State.Pid}}
|
||||
Exit Code: {{.State.ExitCode}}
|
||||
|
||||
Networks:
|
||||
{{range .NetworkSettings.Networks}} • {{.IPAddress}}
|
||||
{{end}}
|
||||
|
||||
Mounts:
|
||||
{{range .Mounts}} • {{.Source}} -> {{.Destination}}
|
||||
{{end}}
|
||||
" {1}
|
||||
)+change-preview-label(Inspect)' |
|
||||
cut -f1
|
||||
) || return
|
||||
|
||||
docker exec -it "$container" sh -c '
|
||||
for shell in bash ash zsh sh; do
|
||||
command -v "$shell" >/dev/null 2>&1 && exec "$shell"
|
||||
done
|
||||
|
||||
echo "No suitable shell found." >&2
|
||||
exit 1
|
||||
'
|
||||
}
|
||||
Reference in New Issue
Block a user