summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Teichmann <erik@eriktdesign.com>2024-09-18 11:26:38 -0700
committerGitHub <noreply@github.com>2024-09-18 20:26:38 +0200
commit9bcafe1c27f62f224c095cd2479763280336090b (patch)
tree21398ccf6d16b1a323cf19f131ddf24323b66f6f
parent3151c9c1a330cdea66dd7d1a24810fe805298711 (diff)
downloadzsh-9bcafe1c27f62f224c095cd2479763280336090b.tar.gz
zsh-9bcafe1c27f62f224c095cd2479763280336090b.tar.bz2
zsh-9bcafe1c27f62f224c095cd2479763280336090b.zip
feat(functions): add `takezip` (#12670)
-rw-r--r--lib/functions.zsh12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 2e667332e..b68c35c13 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -57,6 +57,16 @@ function takeurl() {
cd "$thedir"
}
+function takezip() {
+ local data thedir
+ data="$(mktemp)"
+ curl -L "$1" > "$data"
+ unzip "$data" -d "./"
+ thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
+ rm "$data"
+ cd "$thedir"
+}
+
function takegit() {
git clone "$1"
cd "$(basename ${1%%.git})"
@@ -65,6 +75,8 @@ function takegit() {
function take() {
if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
takeurl "$1"
+ elif [[ $1 =~ ^(https?|ftp).*\.(zip)$ ]]; then
+ takezip "$1"
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit "$1"
else