diff options
author | Marc Cornellà <hello@mcornella.com> | 2022-01-05 09:23:27 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2022-01-05 09:23:55 +0100 |
commit | 67cc59b4258a13232cddfddd75f44d8ca2b80172 (patch) | |
tree | 0723a3023b2c3df14957eab8dabc8ccab94c047b | |
parent | 7ae4f76f6dda1521505c57880ea1e5ee2f1aa183 (diff) | |
download | zsh-67cc59b4258a13232cddfddd75f44d8ca2b80172.tar.gz zsh-67cc59b4258a13232cddfddd75f44d8ca2b80172.tar.bz2 zsh-67cc59b4258a13232cddfddd75f44d8ca2b80172.zip |
style: some code style fixes
-rw-r--r-- | plugins/frontend-search/frontend-search.plugin.zsh | 32 | ||||
-rw-r--r-- | plugins/pj/pj.plugin.zsh | 51 |
2 files changed, 39 insertions, 44 deletions
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 437e477b9..7f8d5c90c 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -39,7 +39,7 @@ function frontend() { emulate -L zsh # define search context URLS - typeset -A urls + local -A urls urls=( angular 'https://angular.io/?search=' angularjs $(_frontend_fallback 'angularjs.org') @@ -73,25 +73,23 @@ function frontend() { ) # show help for command list - if [[ $# -lt 2 ]] - then - print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" - print -P "" - print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," - print -P "and %Ucontext%u is one of the following:" - print -P "" - print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" - print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," - print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" - print -P "" - print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." - print -P "" - return 1 + if [[ $# -lt 2 ]]; then + print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" + print -P "" + print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," + print -P "and %Ucontext%u is one of the following:" + print -P "" + print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" + print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," + print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" + print -P "" + print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." + print -P "" + return 1 fi # check whether the search context is supported - if [[ -z "$urls[$1]" ]] - then + if [[ -z "$urls[$1]" ]]; then echo "Search context \"$1\" currently not supported." echo "" echo "Valid contexts are:" diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index e36d49204..431576f4b 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -1,37 +1,34 @@ alias pjo="pj open" -pj () { - emulate -L zsh - - cmd="cd" - project=$1 - - if [[ "open" == "$project" ]]; then - shift - project=$* - cmd=${=EDITOR} - else - project=$* +function pj() { + local cmd="cd" + local project="$1" + + if [[ "open" == "$project" ]]; then + shift + project=$* + cmd=${=EDITOR} + else + project=$* + fi + + for basedir ($PROJECT_PATHS); do + if [[ -d "$basedir/$project" ]]; then + $cmd "$basedir/$project" + return fi + done - for basedir ($PROJECT_PATHS); do - if [[ -d "$basedir/$project" ]]; then - $cmd "$basedir/$project" - return - fi - done - - echo "No such project '${project}'." + echo "No such project '${project}'." } _pj () { - emulate -L zsh + local -a projects + for basedir ($PROJECT_PATHS); do + projects+=(${basedir}/*(/N)) + done - typeset -a projects - for basedir ($PROJECT_PATHS); do - projects+=(${basedir}/*(/N)) - done - - compadd ${projects:t} + compadd ${projects:t} } + compdef _pj pj |