ebfba0e5392ea9855bfd3ed0ef1b9f49c6a9176f

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

Message

Drop the use of nohup on OSX for tmux compatibility

Apparently `nohup` is not needed in OSX, and using it has the side
that it may break under tmux with the error

  nohup: can't detach from console: No such file or directory

For now, this commit only drops the use of `nohup` in OSX. But it
*may* not be necessary under other similar platforms.

Diff

 1diff --git a/lib/functions.zsh b/lib/functions.zsh
 2index efb73a1bd91170f1c2622635875ceb900942ee43..a25855953736c7777e49b7518b26f0148e421e23 100644
 3--- a/lib/functions.zsh
 4+++ b/lib/functions.zsh
 5@@ -28,7 +28,10 @@ function open_command() {
 6               ;;
 7   esac
 8 
 9-  nohup $open_cmd "$@" &>/dev/null
10+  # don't use nohup on OSX
11+  [[ "$OSTYPE" != darwin* ]] && open_cmd="nohup $open_cmd"
12+
13+  $open_cmd "$@" &>/dev/null
14 }
15 
16 #
17@@ -67,7 +70,7 @@ function try_alias_value() {
18 #
19 # Arguments:
20 #    1. name - The variable to set
21-#    2. val  - The default value 
22+#    2. val  - The default value
23 # Return value:
24 #    0 if the variable exists, 3 if it was set
25 #
26@@ -81,12 +84,12 @@ function default() {
27 #
28 # Arguments:
29 #    1. name - The env variable to set
30-#    2. val  - The default value 
31+#    2. val  - The default value
32 # Return value:
33 #    0 if the env variable exists, 3 if it was set
34 #
35 function env_default() {
36-    env | grep -q "^$1=" && return 0 
37+    env | grep -q "^$1=" && return 0
38     export "$1=$2"       && return 3
39 }
40 
41@@ -101,7 +104,7 @@ zmodload zsh/langinfo
42 #
43 # By default, reserved characters and unreserved "mark" characters are
44 # not escaped by this function. This allows the common usage of passing
45-# an entire URL in, and encoding just special characters in it, with 
46+# an entire URL in, and encoding just special characters in it, with
47 # the expectation that reserved and mark characters are used appropriately.
48 # The -r and -m options turn on escaping of the reserved and mark characters,
49 # respectively, which allows arbitrary strings to be fully escaped for
50@@ -112,7 +115,7 @@ zmodload zsh/langinfo
51 #
52 # Usage:
53 #  omz_urlencode [-r] [-m] <string>
54-#  
55+#
56 #    -r causes reserved characters (;/?:@&=+$,) to be escaped
57 #
58 #    -m causes "mark" characters (_.!~*''()-) to be escaped
59@@ -177,8 +180,8 @@ function omz_urlencode() {
60 # URL-decode a string
61 #
62 # Decodes a RFC 2396 URL-encoded (%-escaped) string.
63-# This decodes the '+' and '%' escapes in the input string, and leaves 
64-# other characters unchanged. Does not enforce that the input is a 
65+# This decodes the '+' and '%' escapes in the input string, and leaves
66+# other characters unchanged. Does not enforce that the input is a
67 # valid URL-encoded string. This is a convenience to allow callers to
68 # pass in a full URL or similar strings and decode them for human
69 # presentation.
70@@ -196,7 +199,7 @@ function omz_urldecode {
71   local caller_encoding=$langinfo[CODESET]
72   local LC_ALL=C
73   export LC_ALL
74-  
75+
76   # Change + back to ' '
77   local tmp=${encoded_url:gs/+/ /}
78   # Protect other escapes to pass through the printf unchanged
79@@ -220,4 +223,3 @@ function omz_urldecode {
80 
81   echo -E "$decoded"
82 }
83-