Skip to content

Instantly share code, notes, and snippets.

@kennycyb
Created May 27, 2025 06:52
Show Gist options
  • Save kennycyb/4997fd79a9a9f2f418c22e6c3c887dfb to your computer and use it in GitHub Desktop.
Save kennycyb/4997fd79a9a9f2f418c22e6c3c887dfb to your computer and use it in GitHub Desktop.
# decrypt gpg and untar to the basename
tgx() {
if [[ $# -ne 1 ]]; then
echo "Usage: tgx <file.tar.gz.gpg>"
return 1
fi
local input_file="$1"
local base_name="${input_file%.tar.gz.gpg}"
local output_dir="${base_name}"
mkdir -p "$output_dir" || {
echo "Failed to create output directory: $output_dir"
return 1
}
echo "Decrypting and extracting $input_file to $output_dir/"
gpg -d "$input_file" | tar -xz -C "$output_dir" || {
echo "Decryption or extraction failed."
return 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment