浏览代码

Implement cross-platform open function open_command()

For now this supports:
- Mac OS X
- Linux (presumably works on all versions)
- Cygwin (Windows)
Marc Cornellà 9 年之前
父节点
当前提交
2d0bfcf818
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      lib/functions.zsh

+ 16 - 0
lib/functions.zsh

@@ -15,6 +15,22 @@ function take() {
   cd $1
 }
 
+function open_command() {
+  local open_cmd
+
+  # define the open command
+  case "$OSTYPE" in
+    darwin*)  open_cmd="open" ;;
+    cygwin*)  open_cmd="cygstart" ;;
+    linux*)   open_cmd="xdg-open" ;;
+    *)        echo "Platform $OSTYPE not supported"
+              return 1
+              ;;
+  esac
+
+  nohup $open_cmd "$@" &>/dev/null
+}
+
 #
 # Get the value of an alias.
 #