9bcafe1c27f62f224c095cd2479763280336090b
- Author
- Erik Teichmann <erik@eriktdesign.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
feat(functions): add `takezip` (#12670)
Diff
1diff --git a/lib/functions.zsh b/lib/functions.zsh
2index 2e667332e956a3b24daf499a5ace0d401bda28ef..b68c35c13dc801419f3a9dbb8773497d7ba2adbd 100644
3--- a/lib/functions.zsh
4+++ b/lib/functions.zsh
5@@ -57,6 +57,16 @@ function takeurl() {
6 cd "$thedir"
7 }
8
9+function takezip() {
10+ local data thedir
11+ data="$(mktemp)"
12+ curl -L "$1" > "$data"
13+ unzip "$data" -d "./"
14+ thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
15+ rm "$data"
16+ cd "$thedir"
17+}
18+
19 function takegit() {
20 git clone "$1"
21 cd "$(basename ${1%%.git})"
22@@ -65,6 +75,8 @@ function takegit() {
23 function take() {
24 if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
25 takeurl "$1"
26+ elif [[ $1 =~ ^(https?|ftp).*\.(zip)$ ]]; then
27+ takezip "$1"
28 elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
29 takegit "$1"
30 else