Skip to content

Instantly share code, notes, and snippets.

@awgreene
Created May 4, 2021 00:12
Show Gist options
  • Save awgreene/fe48456475d8814ba5a9a6d1f5610dcd to your computer and use it in GitHub Desktop.
Save awgreene/fe48456475d8814ba5a9a6d1f5610dcd to your computer and use it in GitHub Desktop.
Allows you to explore the content in a bundle
#!/bin/bash
tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
cd $tmp_dir
trap 'rm -rf -- "$tmp_dir"' EXIT
docker save $1 -o manifest.tar
tar -xf manifest.tar
cd $(ls -d */|head -n 1)
mkdir contents
tar -xf layer.tar -C contents
cd contents
while true; do
echo "Dive into a dir or VI a file: "
opts="$(ls) ../ exit"
select opt in $opts; do
# leave the loop if the user says 'stop'
if [[ "$REPLY" == "../" ]]; then
cd ../
break
fi
if [[ "$REPLY" == "exit" ]]; then
exit 0
fi
if [[ -f "$REPLY" ]]; then
vi $REPLY
break
fi
if [[ -d "$REPLY" ]]; then
cd $REPLY
break
fi
echo "$REPLY is not a valid option"
break
done
clear
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment