Fixes to mpw.completion.bash when no mpsites.
This commit is contained in:
parent
634ef062f3
commit
20d1811b5c
@ -3,38 +3,28 @@ source bashcomplib
|
|||||||
|
|
||||||
# completing the 'mpw' command.
|
# completing the 'mpw' command.
|
||||||
_comp_mpw() {
|
_comp_mpw() {
|
||||||
local optarg= cword=${COMP_WORDS[COMP_CWORD]} pcword
|
local optarg= cword=${COMP_WORDS[COMP_CWORD]} pcword=
|
||||||
|
(( COMP_CWORD )) && pcword=${COMP_WORDS[COMP_CWORD - 1]}
|
||||||
|
|
||||||
if (( COMP_CWORD > 0 )); then
|
case $pcword in
|
||||||
pcword=${COMP_WORDS[COMP_CWORD - 1]}
|
-u) # complete full names.
|
||||||
|
COMPREPLY=( ~/.mpw.d/*.mpsites )
|
||||||
case $pcword in
|
[[ -e $COMPREPLY ]] || COMPREPLY=()
|
||||||
-u) optarg=user ;;
|
COMPREPLY=( "${COMPREPLY[@]##*/}" ) COMPREPLY=( "${COMPREPLY[@]%.mpsites}" )
|
||||||
-t) optarg=type ;;
|
|
||||||
-c) optarg=counter ;;
|
|
||||||
-V) optarg=version ;;
|
|
||||||
-v) optarg=variant ;;
|
|
||||||
-C) optarg=context ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $optarg in
|
|
||||||
user) # complete full names.
|
|
||||||
COMPREPLY=( ~/.mpw.d/*.mpsites ) COMPREPLY=( "${COMPREPLY[@]##*/}" ) COMPREPLY=( "${COMPREPLY[@]%.mpsites}" )
|
|
||||||
;;
|
;;
|
||||||
type) # complete types.
|
-t) # complete types.
|
||||||
COMPREPLY=( maximum long medium basic short pin name phrase )
|
COMPREPLY=( maximum long medium basic short pin name phrase )
|
||||||
;;
|
;;
|
||||||
counter) # complete counter.
|
-c) # complete counter.
|
||||||
COMPREPLY=( 1 )
|
COMPREPLY=( 1 )
|
||||||
;;
|
;;
|
||||||
version) # complete versions.
|
-V) # complete versions.
|
||||||
COMPREPLY=( 0 1 2 3 )
|
COMPREPLY=( 0 1 2 3 )
|
||||||
;;
|
;;
|
||||||
variant) # complete variants.
|
-v) # complete variants.
|
||||||
COMPREPLY=( password login answer )
|
COMPREPLY=( password login answer )
|
||||||
;;
|
;;
|
||||||
context) # complete context.
|
-C) # complete context.
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# previous word is not an option we can complete, complete site name (or option if leading -)
|
# previous word is not an option we can complete, complete site name (or option if leading -)
|
||||||
@ -45,8 +35,31 @@ _comp_mpw() {
|
|||||||
for (( w = 0; w < ${#COMP_WORDS[@]}; ++w )); do
|
for (( w = 0; w < ${#COMP_WORDS[@]}; ++w )); do
|
||||||
[[ ${COMP_WORDS[w]} = -u ]] && fullName=$(xargs <<< "${COMP_WORDS[w + 1]}") && break
|
[[ ${COMP_WORDS[w]} = -u ]] && fullName=$(xargs <<< "${COMP_WORDS[w + 1]}") && break
|
||||||
done
|
done
|
||||||
IFS=$'\n' read -d '' -ra COMPREPLY < <(awk -F$'\t' '!/^ *#/{sub(/^ */, "", $2); print $2}' ~/.mpw.d/"$fullName.mpsites")
|
if [[ -e ~/.mpw.d/"$fullName.mpsites" ]]; then
|
||||||
printf -v _comp_title 'Sites for %s' "$fullName"
|
IFS=$'\n' read -d '' -ra COMPREPLY < <(awk -F$'\t' '!/^ *#/{sub(/^ */, "", $2); print $2}' ~/.mpw.d/"$fullName.mpsites")
|
||||||
|
printf -v _comp_title 'Sites for %s' "$fullName"
|
||||||
|
else
|
||||||
|
# Default list from the Alexa Top 500
|
||||||
|
COMPREPLY=(
|
||||||
|
163.com 360.cn 9gag.com adobe.com alibaba.com aliexpress.com amazon.com
|
||||||
|
apple.com archive.org ask.com baidu.com battle.net booking.com buzzfeed.com
|
||||||
|
chase.com cnn.com comcast.net craigslist.org dailymotion.com dell.com
|
||||||
|
deviantart.com diply.com disqus.com dropbox.com ebay.com engadget.com
|
||||||
|
espn.go.com evernote.com facebook.com fedex.com feedly.com flickr.com
|
||||||
|
flipkart.com github.com gizmodo.com go.com goodreads.com google.com
|
||||||
|
huffingtonpost.com hulu.com ign.com ikea.com imdb.com imgur.com
|
||||||
|
indiatimes.com instagram.com jd.com kickass.to kickstarter.com linkedin.com
|
||||||
|
live.com livedoor.com mail.ru mozilla.org naver.com netflix.com newegg.com
|
||||||
|
nicovideo.jp nytimes.com pandora.com paypal.com pinterest.com pornhub.com
|
||||||
|
qq.com rakuten.co.jp reddit.com redtube.com shutterstock.com skype.com
|
||||||
|
soso.com spiegel.de spotify.com stackexchange.com steampowered.com
|
||||||
|
stumbleupon.com taobao.com target.com thepiratebay.se tmall.com
|
||||||
|
torrentz.eu tripadvisor.com tube8.com tubecup.com tudou.com tumblr.com
|
||||||
|
twitter.com uol.com.br vimeo.com vk.com walmart.com weibo.com whatsapp.com
|
||||||
|
wikia.com wikipedia.org wired.com wordpress.com xhamster.com xinhuanet.com
|
||||||
|
xvideos.com yahoo.com yandex.ru yelp.com youku.com youporn.com ziddu.com
|
||||||
|
)
|
||||||
|
fi
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
_comp_finish_completions
|
_comp_finish_completions
|
||||||
|
Loading…
Reference in New Issue
Block a user