#!/bin/sh -e
#
# pod-shell - shell into a running podman container

if command -v fzy >/dev/null 2>&1; then
  container=$(podman ps --format 'table {{.ID}}\t{{.Status}}\t{{.Command}}' \
    | tail -n +2 | grep -v '/portainer' | fzy | sed 's/\ .*//g')
  podman exec --interactive --tty "${container}" sh -c "clear; (bash || ash || sh)"
else
  podman exec --interactive --tty "$1" sh -c "clear; (bash || ash || sh)"
fi

# container=$(podman ps | rg -v container | awk '-F ' ' { print $NF }' | fzy)
# if [ -n "${container}" ]; then
#   podman exec --interactive --tty "${container}" bash
# fi
