Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
b8dbd9bf
Commit
b8dbd9bf
authored
Aug 12, 2015
by
Robby Russell
Browse files
Merge pull request #4217 from mcornella/standard-open-command
Implement and use a standard, cross-platform open command
parents
4c1eda11
b760a10c
Changes
7
Hide whitespace changes
Inline
Side-by-side
lib/functions.zsh
View file @
b8dbd9bf
...
@@ -15,6 +15,22 @@ function take() {
...
@@ -15,6 +15,22 @@ function take() {
cd
$1
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.
# Get the value of an alias.
#
#
...
...
plugins/fasd/fasd.plugin.zsh
View file @
b8dbd9bf
...
@@ -5,7 +5,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed
...
@@ -5,7 +5,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed
fi
fi
source
"
$fasd_cache
"
source
"
$fasd_cache
"
unset
fasd_cache
unset
fasd_cache
alias
v
=
'f -e vim'
alias
v
=
'f -e vim'
alias
o
=
'a -e open'
alias
o
=
'a -e open
_command
'
fi
fi
plugins/frontend-search/frontend-search.plugin.zsh
View file @
b8dbd9bf
...
@@ -2,14 +2,6 @@
...
@@ -2,14 +2,6 @@
function
frontend
()
{
function
frontend
()
{
# get the open command
local
open_cmd
if
[[
$(
uname
-s
)
==
'Darwin'
]]
;
then
open_cmd
=
'open'
else
open_cmd
=
'xdg-open'
fi
# no keyword provided, simply show how call methods
# no keyword provided, simply show how call methods
if
[[
$#
-le
1
]]
;
then
if
[[
$#
-le
1
]]
;
then
echo
"Please provide a search-content and a search-term for app.
\n
Ex:
\n
frontend <search-content> <search-term>
\n
"
echo
"Please provide a search-content and a search-term for app.
\n
Ex:
\n
frontend <search-content> <search-term>
\n
"
...
@@ -113,7 +105,7 @@ function frontend() {
...
@@ -113,7 +105,7 @@ function frontend() {
echo
"
$url
"
echo
"
$url
"
$
open_c
m
d
"
$url
"
open_c
omman
d
"
$url
"
}
}
...
...
plugins/jira/jira.plugin.zsh
View file @
b8dbd9bf
...
@@ -11,13 +11,6 @@
...
@@ -11,13 +11,6 @@
# Usage: jira # opens a new issue
# Usage: jira # opens a new issue
# jira ABC-123 # Opens an existing issue
# jira ABC-123 # Opens an existing issue
open_jira_issue
()
{
open_jira_issue
()
{
local
open_cmd
if
[[
"
$OSTYPE
"
=
darwin
*
]]
;
then
open_cmd
=
'open'
else
open_cmd
=
'xdg-open'
fi
if
[
-f
.jira-url
]
;
then
if
[
-f
.jira-url
]
;
then
jira_url
=
$(
cat
.jira-url
)
jira_url
=
$(
cat
.jira-url
)
elif
[
-f
~/.jira-url
]
;
then
elif
[
-f
~/.jira-url
]
;
then
...
@@ -39,7 +32,7 @@ open_jira_issue () {
...
@@ -39,7 +32,7 @@ open_jira_issue () {
if
[
-z
"
$1
"
]
;
then
if
[
-z
"
$1
"
]
;
then
echo
"Opening new issue"
echo
"Opening new issue"
$
open_c
m
d
"
${
jira_url
}
/secure/CreateIssue!default.jspa"
open_c
omman
d
"
${
jira_url
}
/secure/CreateIssue!default.jspa"
elif
[[
"
$1
"
=
"assigned"
||
"
$1
"
=
"reported"
]]
;
then
elif
[[
"
$1
"
=
"assigned"
||
"
$1
"
=
"reported"
]]
;
then
jira_query
$@
jira_query
$@
else
else
...
@@ -52,9 +45,9 @@ open_jira_issue () {
...
@@ -52,9 +45,9 @@ open_jira_issue () {
fi
fi
if
[[
"x
$JIRA_RAPID_BOARD
"
=
"xtrue"
]]
;
then
if
[[
"x
$JIRA_RAPID_BOARD
"
=
"xtrue"
]]
;
then
$
open_c
m
d
"
$jira_url
/issues/
$jira_prefix$1$addcomment
"
open_c
omman
d
"
$jira_url
/issues/
$jira_prefix$1$addcomment
"
else
else
$
open_c
m
d
"
$jira_url
/browse/
$jira_prefix$1$addcomment
"
open_c
omman
d
"
$jira_url
/browse/
$jira_prefix$1$addcomment
"
fi
fi
fi
fi
}
}
...
@@ -90,7 +83,7 @@ jira_query () {
...
@@ -90,7 +83,7 @@ jira_query () {
return
1
return
1
fi
fi
echo
"Browsing issues
${
verb
}
${
preposition
}
${
jira_name
}
"
echo
"Browsing issues
${
verb
}
${
preposition
}
${
jira_name
}
"
$
open_c
m
d
"
${
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"
open_c
omman
d
"
${
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"
}
}
alias
jira
=
'open_jira_issue'
alias
jira
=
'open_jira_issue'
...
...
plugins/lighthouse/lighthouse.plugin.zsh
View file @
b8dbd9bf
...
@@ -9,7 +9,7 @@ open_lighthouse_ticket () {
...
@@ -9,7 +9,7 @@ open_lighthouse_ticket () {
else
else
lighthouse_url
=
$(
cat
.lighthouse-url
)
;
lighthouse_url
=
$(
cat
.lighthouse-url
)
;
echo
"Opening ticket #
$1
"
;
echo
"Opening ticket #
$1
"
;
`
open
$lighthouse_url
/tickets/
$1
`
;
open
_command
"
$lighthouse_url
/tickets/
$1
"
;
fi
fi
}
}
...
...
plugins/node/node.plugin.zsh
View file @
b8dbd9bf
# Open the node api for your current version to the optional section.
# Open the node api for your current version to the optional section.
# TODO: Make the section part easier to use.
# TODO: Make the section part easier to use.
function
node-docs
{
function
node-docs
{
# get the open command
open_command
"http://nodejs.org/docs/
$(
node
--version
)
/api/all.html#all_
$1
"
local
open_cmd
if
[[
"
$OSTYPE
"
=
darwin
*
]]
;
then
open_cmd
=
'open'
else
open_cmd
=
'xdg-open'
fi
$open_cmd
"http://nodejs.org/docs/
$(
node
--version
)
/api/all.html#all_
$1
"
}
}
plugins/web-search/web-search.plugin.zsh
View file @
b8dbd9bf
...
@@ -14,16 +14,6 @@ function web_search() {
...
@@ -14,16 +14,6 @@ function web_search() {
github
"https://github.com/search?q="
github
"https://github.com/search?q="
)
)
# 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
# check whether the search engine is supported
# check whether the search engine is supported
if
[[
-z
"
$urls
[
$1
]"
]]
;
then
if
[[
-z
"
$urls
[
$1
]"
]]
;
then
echo
"Search engine
$1
not supported."
echo
"Search engine
$1
not supported."
...
@@ -41,7 +31,7 @@ function web_search() {
...
@@ -41,7 +31,7 @@ function web_search() {
url
=
"
${
(j
://:
)
${
(s
:/:
)urls[
$1
]
}
[1,2]
}
"
url
=
"
${
(j
://:
)
${
(s
:/:
)urls[
$1
]
}
[1,2]
}
"
fi
fi
nohup
$
open_c
m
d
"
$url
"
&>/dev/null
open_c
omman
d
"
$url
"
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment