Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
663ac56d
Commit
663ac56d
authored
Aug 31, 2015
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prettify frontend help output and clean up logic
parent
ff706f3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
55 deletions
+24
-55
frontend-search.plugin.zsh
plugins/frontend-search/frontend-search.plugin.zsh
+24
-55
No files found.
plugins/frontend-search/frontend-search.plugin.zsh
View file @
663ac56d
# frontend from terminal
function
frontend
()
{
function
frontend
()
{
emulate
-L
zsh
emulate
-L
zsh
# define search conte
n
t URLS
# define search conte
x
t URLS
typeset
-A
urls
typeset
-A
urls
urls
=(
urls
=(
angularjs
'https://google.com/search?as_sitesearch=angularjs.org&as_q='
angularjs
'https://google.com/search?as_sitesearch=angularjs.org&as_q='
...
@@ -29,74 +27,45 @@ function frontend() {
...
@@ -29,74 +27,45 @@ function frontend() {
unheap
'http://www.unheap.com/?s='
unheap
'http://www.unheap.com/?s='
)
)
# show help for command
s
list
# show help for command list
if
[[
$
1
=
~
'(help|--help|-h)'
]]
if
[[
$
#
-lt
2
]]
then
then
echo
"Usage:"
print
-P
"Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
echo
"
\n\t
frontend <search-content>
\n\t
<search-content>
\n\t
frontend <search-content> <search-term>"
print
-P
""
echo
""
print
-P
"%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
echo
"Where <search-content> is one of:"
print
-P
"and %Ucontext%u is one of the following:"
echo
"jquery, mdn, compass, html5please, caniuse, aurajs, dartlang, qunit, fontello,"
print
-P
""
echo
"bootsnipp, cssflow, codepen, unheap, bem, smacss, angularjs, reactjs, emberjs"
print
-P
" angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow,"
echo
"help"
print
-P
" dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
echo
""
print
-P
" qunit, reactjs, smacss, stackoverflow, unheap"
echo
"Where <search-term> is a term to search in allowed repositories"
print
-P
""
echo
""
print
-P
"For example: frontend npmjs mocha (or just: npmjs mocha)."
echo
"frontend --help show plugin help"
print
-P
""
echo
"frontend -h show plugin help"
echo
""
echo
"It is allowed to directly access all search contents."
echo
""
return
1
return
1
fi
fi
# no keyword provided, simply show how call methods
# check whether the search context is supported
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
"
return
1
fi
# check whether the search engine is supported
if
[[
-z
"
$urls
[
$1
]"
]]
if
[[
-z
"
$urls
[
$1
]"
]]
then
then
echo
"Search valid search content
$1
not supported."
echo
"Search context
\"
$1
\"
currently not supported."
echo
"Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
echo
""
echo
"* jquery"
echo
"Valid contexts are:"
echo
"* mdn"
echo
""
echo
"* compass"
echo
" angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compass, cssflow, "
echo
"* html5please"
echo
" dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
echo
"* caniuse"
echo
" qunit, reactjs, smacss, stackoverflow, unheap"
echo
"* aurajs"
echo
"* dartlang"
echo
"* lodash"
echo
"* qunit"
echo
"* fontello"
echo
"* bootsnipp"
echo
"* cssflow"
echo
"* codepen"
echo
"* unheap"
echo
"* bem"
echo
"* smacss"
echo
"* angularjs"
echo
"* reactjs"
echo
"* emberjs"
echo
"* stackoverflow"
echo
"* npmjs"
echo
""
echo
""
return
1
return
1
fi
fi
# build search url:
# build search url:
# join arguments passed with '+', then append to search
engine
URL
# join arguments passed with '+', then append to search
context
URL
# TODO substitute for proper urlencode method
# TODO substitute for proper urlencode method
url
=
"
${
urls
[
$1
]
}${
(j
:+:
)@[2,-1]
}
"
url
=
"
${
urls
[
$1
]
}${
(j
:+:
)@[2,-1]
}
"
echo
"
$url
"
echo
"
Opening
$url
...
"
open_command
"
$url
"
open_command
"
$url
"
}
}
# javascript
# javascript
...
...
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