style: some code style fixes

This commit is contained in:
Marc Cornellà 2022-01-05 09:23:27 +01:00
parent 7ae4f76f6d
commit 67cc59b425
No known key found for this signature in database
GPG Key ID: 0314585E776A9C1B
2 changed files with 37 additions and 42 deletions

View File

@ -39,7 +39,7 @@ function frontend() {
emulate -L zsh emulate -L zsh
# define search context URLS # define search context URLS
typeset -A urls local -A urls
urls=( urls=(
angular 'https://angular.io/?search=' angular 'https://angular.io/?search='
angularjs $(_frontend_fallback 'angularjs.org') angularjs $(_frontend_fallback 'angularjs.org')
@ -73,25 +73,23 @@ function frontend() {
) )
# show help for command list # show help for command list
if [[ $# -lt 2 ]] if [[ $# -lt 2 ]]; then
then print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" print -P ""
print -P "" print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
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 "and %Ucontext%u is one of the following:" print -P ""
print -P "" print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
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 " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" print -P ""
print -P "" print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." print -P ""
print -P "" return 1
return 1
fi fi
# check whether the search context is supported # check whether the search context is supported
if [[ -z "$urls[$1]" ]] if [[ -z "$urls[$1]" ]]; then
then
echo "Search context \"$1\" currently not supported." echo "Search context \"$1\" currently not supported."
echo "" echo ""
echo "Valid contexts are:" echo "Valid contexts are:"

View File

@ -1,37 +1,34 @@
alias pjo="pj open" alias pjo="pj open"
pj () { function pj() {
emulate -L zsh local cmd="cd"
local project="$1"
cmd="cd" if [[ "open" == "$project" ]]; then
project=$1 shift
project=$*
cmd=${=EDITOR}
else
project=$*
fi
if [[ "open" == "$project" ]]; then for basedir ($PROJECT_PATHS); do
shift if [[ -d "$basedir/$project" ]]; then
project=$* $cmd "$basedir/$project"
cmd=${=EDITOR} return
else
project=$*
fi fi
done
for basedir ($PROJECT_PATHS); do echo "No such project '${project}'."
if [[ -d "$basedir/$project" ]]; then
$cmd "$basedir/$project"
return
fi
done
echo "No such project '${project}'."
} }
_pj () { _pj () {
emulate -L zsh local -a projects
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
typeset -a projects compadd ${projects:t}
for basedir ($PROJECT_PATHS); do
projects+=(${basedir}/*(/N))
done
compadd ${projects:t}
} }
compdef _pj pj compdef _pj pj