shells/zsh: add mktmpunzip and mktmpclone

This commit is contained in:
Infinidoge 2024-10-16 02:01:24 -04:00
parent 267eea060c
commit 34cd8add4a
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A

View file

@ -48,6 +48,36 @@
alias "jh"="cd ~ && j"
alias "gj"="gcd && j"
mktmpunzip() {
dir=$(mktemp -t -d unzip.XXX)
if ! file=$(realpath -e "$1"); then
echo "error: file does not exist"
return 1
fi
shift 1
unzip "$file" "$@" -d "$dir"
\builtin cd $dir
mv $file .
}
mktmpclone() {
location="$1"
if [ "$2" != "" ]; then
dirspec="$2.XXX"
shift 2
else
dirspec="clone.XXX"
shift 1
fi
if ! dir=$(mktemp -t -d "$dirspec"); then
echo "error: couldn't create temp directory"
return 1
fi
git clone "$location" "$dir" "$@"
\builtin cd "$dir"
}
'';
dotDir = ".config/zsh";