⚡ refacts bash/profile setup
This commit is contained in:
134
.bash/shell/completion/cordova.completion
Normal file
134
.bash/shell/completion/cordova.completion
Normal file
@@ -0,0 +1,134 @@
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
platforms() {
|
||||
get_cordova && COMPREPLY=( $(compgen -W "$(${CORDOVA_BIN} platform ls | tr -d "[]',")" -- $1) )
|
||||
}
|
||||
|
||||
plugins() {
|
||||
get_cordova && COMPREPLY=( $(compgen -W "$(${CORDOVA_BIN} plugin ls | tr -d "[]',")" -- $1) )
|
||||
}
|
||||
|
||||
get_cordova() {
|
||||
local cordova
|
||||
if [[ -n "${CORDOVA_BIN}" ]]; then return 0; fi
|
||||
cordova=$(eval echo ${COMP_WORDS[0]})
|
||||
if [[ -x $cordova ]]; then CORDOVA_BIN=$cordova; return 0; fi
|
||||
cordova=$(which cordova)
|
||||
if [[ $? -eq 0 ]]; then CORDOVA_BIN=$cordova; return 0; fi
|
||||
return 1
|
||||
}
|
||||
|
||||
get_top_level_dir() {
|
||||
local path
|
||||
path=$(pwd)
|
||||
while [ $path != '/' ]; do
|
||||
if [ -d $path/.cordova ]; then
|
||||
echo $path
|
||||
return 0
|
||||
fi
|
||||
path=$(dirname $path)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
_cordova()
|
||||
{
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
# Skip over any initial command line switches
|
||||
local i=1
|
||||
while [[ $i -lt ${#COMP_WORDS[*]} ]] && [[ "${COMP_WORDS[${i}]}" == -* ]]; do
|
||||
i=$((i+1));
|
||||
done
|
||||
|
||||
# For the first word, supply all of the valid top-level commands
|
||||
if [[ ${COMP_CWORD} -eq $i ]]; then
|
||||
opts="help create info platform plugin prepare compile build clean run emulate serve"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "${COMP_WORDS[$i]}" in
|
||||
create)
|
||||
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
|
||||
COMPREPLY=( $(compgen -d -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
platform)
|
||||
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
|
||||
opts="add rm remove ls"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
case "${COMP_WORDS[$((i+1))]}" in
|
||||
add)
|
||||
opts="ios android wp7 wp8 blackberry www"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0;
|
||||
;;
|
||||
rm|remove)
|
||||
platforms ${cur}
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
plugin)
|
||||
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
|
||||
opts="add rm remove ls"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
case "${COMP_WORDS[$((i+1))]}" in
|
||||
add)
|
||||
COMPREPLY=( $(compgen nospace -d -- ${cur}) )
|
||||
return 0;
|
||||
;;
|
||||
rm|remove)
|
||||
plugins ${cur}
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
prepare|compile|emulate)
|
||||
platforms ${cur}
|
||||
return 0
|
||||
;;
|
||||
build)
|
||||
platforms ${cur}
|
||||
COMPREPLY+=( $(compgen -W '--release --debug --help --device --emulator --buildConfig' -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
run)
|
||||
platforms ${cur}
|
||||
COMPREPLY+=( $(compgen -W '--list --noprepare --nobuild --target --release --debug --help --device --emulator --buildConfig' -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
serve)
|
||||
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
|
||||
platforms ${cur}
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
complete -F _cordova cordova
|
||||
32
.bash/shell/completion/pnpm.completion
Normal file
32
.bash/shell/completion/pnpm.completion
Normal file
@@ -0,0 +1,32 @@
|
||||
###-begin-pnpm-completion-###
|
||||
if type complete &>/dev/null; then
|
||||
_pnpm_completion () {
|
||||
local words cword
|
||||
if type _get_comp_words_by_ref &>/dev/null; then
|
||||
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword
|
||||
else
|
||||
cword="$COMP_CWORD"
|
||||
words=("${COMP_WORDS[@]}")
|
||||
fi
|
||||
|
||||
local si="$IFS"
|
||||
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
|
||||
COMP_LINE="$COMP_LINE" \
|
||||
COMP_POINT="$COMP_POINT" \
|
||||
SHELL=bash \
|
||||
pnpm completion-server -- "${words[@]}" \
|
||||
2>/dev/null)) || return $?
|
||||
IFS="$si"
|
||||
|
||||
if [ "$COMPREPLY" = "__tabtab_complete_files__" ]; then
|
||||
COMPREPLY=($(compgen -f -- "$cword"))
|
||||
fi
|
||||
|
||||
if type __ltrim_colon_completions &>/dev/null; then
|
||||
__ltrim_colon_completions "${words[cword]}"
|
||||
fi
|
||||
}
|
||||
complete -o default -F _pnpm_completion pnpm
|
||||
fi
|
||||
###-end-pnpm-completion-###
|
||||
|
||||
Reference in New Issue
Block a user