lib/helpers: add `preview` to `bash-it` spaghetti

pull/2017/head
John D Pell 2022-01-25 12:57:23 -08:00
parent d6555f369a
commit a9a40a3cad
4 changed files with 16 additions and 10 deletions

View File

@ -13,7 +13,7 @@ function _bash-it() {
prev="${COMP_WORDS[COMP_CWORD - 1]}" prev="${COMP_WORDS[COMP_CWORD - 1]}"
verb="${COMP_WORDS[1]}" verb="${COMP_WORDS[1]}"
file_type="${COMP_WORDS[2]:-}" file_type="${COMP_WORDS[2]:-}"
candidates=('disable' 'enable' 'help' 'migrate' 'reload' 'restart' 'profile' 'doctor' 'search' 'show' 'update' 'version') candidates=('disable' 'enable' 'help' 'migrate' 'reload' 'restart' 'preview' 'profile' 'doctor' 'search' 'show' 'update' 'version')
case "${verb}" in case "${verb}" in
show) show)
candidates=('aliases' 'completions' 'plugins') candidates=('aliases' 'completions' 'plugins')
@ -58,7 +58,7 @@ function _bash-it() {
fi fi
_compreply_candidates _compreply_candidates
;; ;;
migrate | reload | restart | search | version) ;; migrate | reload | restart | preview | search | version) ;;
enable | disable) enable | disable)
if [[ "${verb}" == "enable" ]]; then if [[ "${verb}" == "enable" ]]; then
suffix="disabled" suffix="disabled"

View File

@ -22,7 +22,7 @@ Examples:
# Disable theming # Disable theming
export BASH_IT_THEME="" export BASH_IT_THEME=""
You can easily preview the themes in your own shell using ``BASH_PREVIEW=true bash-it reload``. You can easily preview the themes in your own shell using ``bash-it preview``.
If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request. If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request.
You can see theme screenshots on `wiki/Themes <https://github.com/Bash-it/bash-it/wiki/Themes>`_. You can see theme screenshots on `wiki/Themes <https://github.com/Bash-it/bash-it/wiki/Themes>`_.

View File

@ -98,7 +98,7 @@ alias reload_plugins="$(_make_reload_alias plugin plugins)"
function bash-it() { function bash-it() {
about 'Bash-it help and maintenance' about 'Bash-it help and maintenance'
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload | restart | doctor ] ' param '1: verb [one of: help | show | enable | disable | migrate | update | search | preview | version | reload | restart | doctor ] '
param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)' param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)'
param '3: specific component [optional]' param '3: specific component [optional]'
example '$ bash-it show plugins' example '$ bash-it show plugins'
@ -108,6 +108,8 @@ function bash-it() {
example '$ bash-it migrate' example '$ bash-it migrate'
example '$ bash-it update' example '$ bash-it update'
example '$ bash-it search [-|@]term1 [-|@]term2 ... [ -e/--enable ] [ -d/--disable ] [ -r/--refresh ] [ -c/--no-color ]' example '$ bash-it search [-|@]term1 [-|@]term2 ... [ -e/--enable ] [ -d/--disable ] [ -r/--refresh ] [ -c/--no-color ]'
example '$ bash-it preview'
example '$ bash-it preview essential'
example '$ bash-it version' example '$ bash-it version'
example '$ bash-it reload' example '$ bash-it reload'
example '$ bash-it restart' example '$ bash-it restart'
@ -142,6 +144,10 @@ function bash-it() {
_bash-it-search "$component" "$@" _bash-it-search "$component" "$@"
return return
;; ;;
preview)
_bash-it-preview "$component" "$@"
return
;;
update) update)
func="_bash-it-update-$component" func="_bash-it-update-$component"
;; ;;

View File

@ -81,32 +81,32 @@ function __check_completion () {
@test "completion bash-it: show options" { @test "completion bash-it: show options" {
run __check_completion 'bash-it ' run __check_completion 'bash-it '
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version" assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version"
} }
@test "completion bash-it: bash-ti - show options" { @test "completion bash-it: bash-ti - show options" {
run __check_completion 'bash-ti ' run __check_completion 'bash-ti '
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version" assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version"
} }
@test "completion bash-it: shit - show options" { @test "completion bash-it: shit - show options" {
run __check_completion 'shit ' run __check_completion 'shit '
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version" assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version"
} }
@test "completion bash-it: bashit - show options" { @test "completion bash-it: bashit - show options" {
run __check_completion 'bashit ' run __check_completion 'bashit '
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version" assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version"
} }
@test "completion bash-it: batshit - show options" { @test "completion bash-it: batshit - show options" {
run __check_completion 'batshit ' run __check_completion 'batshit '
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version" assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version"
} }
@test "completion bash-it: bash_it - show options" { @test "completion bash-it: bash_it - show options" {
run __check_completion 'bash_it ' run __check_completion 'bash_it '
assert_line -n 0 "disable enable help migrate reload restart profile doctor search show update version" assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version"
} }
@test "completion bash-it: profile - show options" { @test "completion bash-it: profile - show options" {