Skip to content

Instantly share code, notes, and snippets.

@zedmatrix
Created February 19, 2026 20:40
Show Gist options
  • Select an option

  • Save zedmatrix/f5b0d8d3e1ebc43485ca7a823a50c6b7 to your computer and use it in GitHub Desktop.

Select an option

Save zedmatrix/f5b0d8d3e1ebc43485ca7a823a50c6b7 to your computer and use it in GitHub Desktop.
Some Quick Bash Functions
#!/bin/sh
## Quick untar and Change to directory
xtar() {
[ -z "$1" ] && { echo "Requires Package Name. Exiting."; return 1; }
local file="$1"
local dir
dir=$(tar -tf "$file" | head -1 | cut -d'/' -f1)
tar -xf "$file" || { echo "Tar extraction failed"; return 1; }
cd "$dir" || { echo "Failed to cd into $dir"; return 1; }
}
export -f xtar
## Create and Change to directory
mcd() {
mkdir -v $1
cd $1
}
export -f mcd
## Quick Create both checksums
ChekSums() {
[ -z "$1" ] && { echo "Requires Package Name. Exiting."; return 1; }
if [[ -f "$1" ]]; then
echo "SHA256: $(sha256sum $1)"
echo "MD5: $(md5sum $1)"
else
echo "File Does Not Exist"
fi
}
export -f ChekSums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment