Skip to content

Instantly share code, notes, and snippets.

@bionade24
Last active February 4, 2024 12:08
Show Gist options
  • Save bionade24/54aa86c909023a2a5a68948a3b59d61d to your computer and use it in GitHub Desktop.
Save bionade24/54aa86c909023a2a5a68948a3b59d61d to your computer and use it in GitHub Desktop.
unzip wrapper to unzip into a new dir
#!/usr/bin/env bash
#If arguments are provided or called by another script, use normal unzip behaviour
if [[ (($# > 1)) || ( (($SHLVL > 2)) && -z ${TMUX} ) || (($SHLVL > 3)) ]]; then
/usr/bin/unzip "$@";
else
NAME=$(echo "${1}" | sed s/\ /_/g | sed s/\.zip//)
mkdir $NAME
/usr/bin/unzip "${1}" -d "$NAME";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment