summaryrefslogtreecommitdiff
path: root/lib/functions.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/functions.zsh')
-rw-r--r--lib/functions.zsh34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 9cc735196..73b491a59 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -13,10 +13,6 @@ function upgrade_oh_my_zsh() {
omz update
}
-function takedir() {
- mkdir -p $@ && cd ${@:$#}
-}
-
function open_command() {
local open_cmd
@@ -37,27 +33,35 @@ function open_command() {
${=open_cmd} "$@" &>/dev/null
}
+# take functions
+
+# mkcd is equivalent to takedir
+function mkcd takedir() {
+ mkdir -p $@ && cd ${@:$#}
+}
+
function takeurl() {
- data=$(mktemp)
- curl -L $1 > $data
- tar xf $data
- thedir=$(tar tf $data | head -1)
- rm $data
- cd $thedir
+ local data thedir
+ 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})
+ git clone "$1"
+ cd "$(basename ${1%%.git})"
}
function take() {
if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
- takeurl $1
+ takeurl "$1"
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
- takegit $1
+ takegit "$1"
else
- takedir $1
+ takedir "$@"
fi
}