76 lines
2.5 KiB
Bash
Executable File
76 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
### Help
|
|
help() {
|
|
echo -e "\nUse fzf to search Pokemon stats\n"
|
|
echo -e "Can optionally search by name"
|
|
echo -e "EXAMPLE\n\tpokedex [pokemon name]\n"
|
|
echo -e "OPTIONS"
|
|
echo -e "\t-q, --quick [pokemon]\n\t\tPrints single pokedex entry to terminal\n\t-u, --update [N/+N/-N/N%]\n\t\tScrape web for updated Pokemon stats\n\t\tWARNING: update function is resource heavy\n\t\tSee Parallel job control (-j) for options\n\t\tDefault is 200%\n\t-h, --help\n\t\tPrint this help screen"
|
|
echo -e "KEYBINDS"
|
|
echo -e "\tctrl-n\tShows small sprite version\n\tctrl-b\tShows large sprite version\n\tctrl-s\tShows shiny sprite version\n\tctrl-h\tShows this help screen in preview window\n"
|
|
}
|
|
|
|
### Set pokeData location
|
|
POKEDATA="/usr/share/fuzzy-pokedex/pokeData"
|
|
|
|
### Pokedex viewer using pokemon-colorscripts and fzf
|
|
pokedex() {
|
|
pokemon-colorscripts -l |
|
|
fzf -q "$1" +m -s -i \
|
|
--cycle \
|
|
--reverse \
|
|
--prompt=' ' \
|
|
--pointer=' ' \
|
|
--border=rounded \
|
|
--border-label="╢ Fuzzy-Pokedex ╟" \
|
|
--margin=4% \
|
|
--padding=4% \
|
|
--header="Choose Pokemon to view info" \
|
|
--info=inline:' ' \
|
|
--color='fg+:15,fg:42,preview-fg:15,label:9,preview-label:15,hl+:134,hl:123,query:134,gutter:0,border:9,prompt:15,pointer:15,marker:15' \
|
|
--tiebreak=begin,chunk,length \
|
|
--preview="echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA/{1}" \
|
|
--preview-window=68%:wrap:border-rounded \
|
|
--bind=focus:transform-preview-label:'echo [ {1} ] ' \
|
|
--bind=ctrl-h:preview:"echo; pokedex -h;" \
|
|
--bind=ctrl-b:preview:"echo; pokemon-colorscripts -b -n {1} --no-title; cat $POKEDATA/{1};" \
|
|
--bind=ctrl-s:preview:"echo; pokemon-colorscripts -s -n {1} --no-title; cat $POKEDATA/{1};" \
|
|
--bind=ctrl-n:preview:"echo; pokemon-colorscripts -n {1} --no-title; cat $POKEDATA{/1};" |
|
|
parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}"
|
|
}
|
|
|
|
|
|
### Quick view returns single Pokemon stat instead of opening pokedex
|
|
quick_view() {
|
|
parallel pokemon-colorscripts --no-title -n {} "&&" cat "$POKEDATA/{}" <<<"$1"
|
|
}
|
|
|
|
### Update Pokemon stats file set
|
|
update_pokeData() {
|
|
echo -e "\n\t\tWARNING!!!\n\tThis WILL take a long time\n"
|
|
pokemon-colorscripts -l | sort | parallel --bar --color --retry-failed -j "${1:-200%}" pokeInfo {} ">" "$POKEDATA/{}" 2>&1
|
|
}
|
|
|
|
if [[ ! "$1" =~ ^- ]]; then
|
|
pokedex "$1"
|
|
else
|
|
for opt in "$@"; do
|
|
case $opt in
|
|
-q|--quick)
|
|
quick_view "$2"
|
|
;;
|
|
-u|--update)
|
|
update_pokeData "$2"
|
|
;;
|
|
-h|--help)
|
|
help
|
|
;;
|
|
-*)
|
|
echo "Invalid Usage"
|
|
help
|
|
;;
|
|
esac
|
|
done
|
|
fi
|