2d0bfcf81846ea4cb0fe2a42f3dac7f2c60e77b7

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Implement cross-platform open function open_command()

For now this supports:
- Mac OS X
- Linux (presumably works on all versions)
- Cygwin (Windows)

Diff

 1diff --git a/lib/functions.zsh b/lib/functions.zsh
 2index 17f5f9cbf246ff0e6c58abfff6dff3ea227c99d8..0d632a2686693f5d624ebd17694d9c4e18bc3d3e 100644
 3--- a/lib/functions.zsh
 4+++ b/lib/functions.zsh
 5@@ -15,6 +15,22 @@ function take() {
 6   cd $1
 7 }
 8 
 9+function open_command() {
10+  local open_cmd
11+
12+  # define the open command
13+  case "$OSTYPE" in
14+    darwin*)  open_cmd="open" ;;
15+    cygwin*)  open_cmd="cygstart" ;;
16+    linux*)   open_cmd="xdg-open" ;;
17+    *)        echo "Platform $OSTYPE not supported"
18+              return 1
19+              ;;
20+  esac
21+
22+  nohup $open_cmd "$@" &>/dev/null
23+}
24+
25 #
26 # Get the value of an alias.
27 #