diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2021-07-11 19:58:51 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2021-07-11 19:58:51 -0600 |
commit | 617ed3bd9f3d9519fe2354941f3dbf15b0c712ee (patch) | |
tree | caf617b35d3f5f7b5786483eedfcda9361dca108 /lib/functions.zsh | |
parent | 0144641b7d8e4e6ff6ce153039b5a827f5347904 (diff) | |
parent | 36f444ed7325720ec05f182781ec7d6c9a4d675c (diff) | |
download | zsh-617ed3bd9f3d9519fe2354941f3dbf15b0c712ee.tar.gz zsh-617ed3bd9f3d9519fe2354941f3dbf15b0c712ee.tar.bz2 zsh-617ed3bd9f3d9519fe2354941f3dbf15b0c712ee.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'lib/functions.zsh')
-rw-r--r-- | lib/functions.zsh | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh index c4340f16c..9cc735196 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -13,7 +13,7 @@ function upgrade_oh_my_zsh() { omz update } -function take() { +function takedir() { mkdir -p $@ && cd ${@:$#} } @@ -37,6 +37,30 @@ function open_command() { ${=open_cmd} "$@" &>/dev/null } +function takeurl() { + data=$(mktemp) + curl -L $1 > $data + tar xf $data + thedir=$(tar tf $data | head -1) + rm $data + cd $thedir +} + +function takegit() { + git clone $1 + cd $(basename ${1%%.git}) +} + +function take() { + if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then + takeurl $1 + elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then + takegit $1 + else + takedir $1 + fi +} + # # Get the value of an alias. # |