Skip to content

Instantly share code, notes, and snippets.

@davegallant
Last active February 11, 2025 03:47
Show Gist options
  • Save davegallant/d717d0a6cd299999331d67ed7573ae19 to your computer and use it in GitHub Desktop.
Save davegallant/d717d0a6cd299999331d67ed7573ae19 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# pct-enter [container-name]
# If container-name is not provided, a fzf prompt will be displayed.
containers=$(pct list | tail -n +2 | awk '{print $3" - "$1}')
if [ $# -eq 0 ]; then
selected_container=$(echo "$containers" | fzf)
else
selected_container=$(echo "$containers" | grep "$1")
fi
if [ -z "$selected_container" ]; then
echo "No container selected."
exit 1
fi
container_id=$(echo "$selected_container" | awk '{print $3}')
pct enter $container_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment