summaryrefslogtreecommitdiff
path: root/lib/functions.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/functions.zsh')
-rw-r--r--lib/functions.zsh20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 9f11318d2..4ef8920f6 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -11,21 +11,20 @@ function upgrade_oh_my_zsh() {
}
function take() {
- mkdir -p $1
- cd $1
+ mkdir -p $@ && cd ${@:$#}
}
function open_command() {
- emulate -L zsh
- setopt shwordsplit
-
local open_cmd
# define the open command
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
- linux*) open_cmd='xdg-open' ;;
+ linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || {
+ open_cmd='cmd.exe /c start ""'
+ [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
+ } ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1
@@ -34,9 +33,9 @@ function open_command() {
# don't use nohup on OSX
if [[ "$OSTYPE" == darwin* ]]; then
- $open_cmd "$@" &>/dev/null
+ ${=open_cmd} "$@" &>/dev/null
else
- nohup $open_cmd "$@" &>/dev/null
+ nohup ${=open_cmd} "$@" &>/dev/null
fi
}
@@ -52,8 +51,7 @@ function open_command() {
# 1 if it does not exist
#
function alias_value() {
- alias "$1" | sed "s/^$1='\(.*\)'$/\1/"
- test $(alias "$1")
+ (( $+aliases[$1] )) && echo $aliases[$1]
}
#
@@ -86,7 +84,7 @@ function default() {
}
#
-# Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined.
+# Set environment variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The env variable to set