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 #
28diff --git a/plugins/fasd/fasd.plugin.zsh b/plugins/fasd/fasd.plugin.zsh
29index 472ab2b0f6b630d3c68c0de835ff4695f6306a75..b11f0b511f68ea343dcf6e090db26c9975b8fd0e 100644
30--- a/plugins/fasd/fasd.plugin.zsh
31+++ b/plugins/fasd/fasd.plugin.zsh
32@@ -5,7 +5,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed
33 fi
34 source "$fasd_cache"
35 unset fasd_cache
36+
37 alias v='f -e vim'
38- alias o='a -e open'
39+ alias o='a -e open_command'
40 fi
41-
42diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
43index b9fb8634c66f15619247713d82febeeb28fbfeeb..f7485621bf444e479a6bd23e37eef220d733d317 100644
44--- a/plugins/frontend-search/frontend-search.plugin.zsh
45+++ b/plugins/frontend-search/frontend-search.plugin.zsh
46@@ -2,14 +2,6 @@
47
48 function frontend() {
49
50- # get the open command
51- local open_cmd
52- if [[ $(uname -s) == 'Darwin' ]]; then
53- open_cmd='open'
54- else
55- open_cmd='xdg-open'
56- fi
57-
58 # no keyword provided, simply show how call methods
59 if [[ $# -le 1 ]]; then
60 echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend <search-content> <search-term>\n"
61@@ -113,7 +105,7 @@ function frontend() {
62
63 echo "$url"
64
65- $open_cmd "$url"
66+ open_command "$url"
67
68 }
69
70diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
71index ca540c84c1229cbea6d0bb0ae721499e2ce41364..9a89327028a8acb9d36dbcd10a7eaf343f29a41f 100644
72--- a/plugins/jira/jira.plugin.zsh
73+++ b/plugins/jira/jira.plugin.zsh
74@@ -11,13 +11,6 @@
75 # Usage: jira # opens a new issue
76 # jira ABC-123 # Opens an existing issue
77 open_jira_issue () {
78- local open_cmd
79- if [[ "$OSTYPE" = darwin* ]]; then
80- open_cmd='open'
81- else
82- open_cmd='xdg-open'
83- fi
84-
85 if [ -f .jira-url ]; then
86 jira_url=$(cat .jira-url)
87 elif [ -f ~/.jira-url ]; then
88@@ -39,7 +32,7 @@ open_jira_issue () {
89
90 if [ -z "$1" ]; then
91 echo "Opening new issue"
92- $open_cmd "${jira_url}/secure/CreateIssue!default.jspa"
93+ open_command "${jira_url}/secure/CreateIssue!default.jspa"
94 elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then
95 jira_query $@
96 else
97@@ -52,9 +45,9 @@ open_jira_issue () {
98 fi
99
100 if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
101- $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment"
102+ open_command "$jira_url/issues/$jira_prefix$1$addcomment"
103 else
104- $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment"
105+ open_command "$jira_url/browse/$jira_prefix$1$addcomment"
106 fi
107 fi
108 }
109@@ -90,7 +83,7 @@ jira_query () {
110 return 1
111 fi
112 echo "Browsing issues ${verb} ${preposition} ${jira_name}"
113- $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
114+ open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
115 }
116
117 alias jira='open_jira_issue'
118diff --git a/plugins/lighthouse/lighthouse.plugin.zsh b/plugins/lighthouse/lighthouse.plugin.zsh
119index 7661c6add6124a30a9544c47fdd4521657e3d69f..48cddbccc7e015257a7928f82e765b4a8acf7eb7 100644
120--- a/plugins/lighthouse/lighthouse.plugin.zsh
121+++ b/plugins/lighthouse/lighthouse.plugin.zsh
122@@ -9,7 +9,7 @@ open_lighthouse_ticket () {
123 else
124 lighthouse_url=$(cat .lighthouse-url);
125 echo "Opening ticket #$1";
126- `open $lighthouse_url/tickets/$1`;
127+ open_command "$lighthouse_url/tickets/$1";
128 fi
129 }
130
131diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh
132index 39d8b10d99324b60c6b01155ac8b9401b4b57aa0..2463815aca572c54cb08dda1bc4a69335225aacd 100644
133--- a/plugins/node/node.plugin.zsh
134+++ b/plugins/node/node.plugin.zsh
135@@ -1,13 +1,5 @@
136 # Open the node api for your current version to the optional section.
137 # TODO: Make the section part easier to use.
138 function node-docs {
139- # get the open command
140- local open_cmd
141- if [[ "$OSTYPE" = darwin* ]]; then
142- open_cmd='open'
143- else
144- open_cmd='xdg-open'
145- fi
146-
147- $open_cmd "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
148+ open_command "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
149 }
150diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh
151index d407edb964f67a222a630eb16c22573d6e05e655..7c3ad9046458199d8cbf224cae49c0081425dedd 100644
152--- a/plugins/web-search/web-search.plugin.zsh
153+++ b/plugins/web-search/web-search.plugin.zsh
154@@ -14,16 +14,6 @@ function web_search() {
155 github "https://github.com/search?q="
156 )
157
158- # define the open command
159- case "$OSTYPE" in
160- darwin*) open_cmd="open" ;;
161- cygwin*) open_cmd="cygstart" ;;
162- linux*) open_cmd="xdg-open" ;;
163- *) echo "Platform $OSTYPE not supported"
164- return 1
165- ;;
166- esac
167-
168 # check whether the search engine is supported
169 if [[ -z "$urls[$1]" ]]; then
170 echo "Search engine $1 not supported."
171@@ -41,7 +31,7 @@ function web_search() {
172 url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
173 fi
174
175- nohup $open_cmd "$url" &>/dev/null
176+ open_command "$url"
177 }
178
179