From d79db3b7e38780ddb0cacce45a6f155a6ab2daf0 Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Tue, 10 Apr 2018 17:12:22 +0800 Subject: [PATCH 1/7] Add support for pyenv-virtualenv --- plugins/available/virtualenv.plugin.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index 651bfec7..570a03d2 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -3,7 +3,11 @@ cite about-plugin about-plugin 'virtualenvwrapper helper functions' -[[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh +if [[ `command -v pyenv` ]]; then + pyenv virtualenvwrapper +else + [[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh +fi function mkvenv { From a9d75c12a00aedd7a856844b522215432b284b4a Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Wed, 11 Apr 2018 14:59:56 +0800 Subject: [PATCH 2/7] Change to _command_exists helper --- plugins/available/virtualenv.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index 570a03d2..468870cd 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -1,9 +1,9 @@ # make sure virtualenvwrapper is enabled if available cite about-plugin -about-plugin 'virtualenvwrapper helper functions' +about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions' -if [[ `command -v pyenv` ]]; then +if _command_exists pyenv; then pyenv virtualenvwrapper else [[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh From cd983294ec3a362f1985e7e8dbd22fd6c2cb48ff Mon Sep 17 00:00:00 2001 From: Florian Molitorisz Date: Wed, 11 Apr 2018 17:37:29 +0200 Subject: [PATCH 3/7] fix hostname prompt https://github.com/Bash-it/bash-it/issues/1145 --- themes/powerline-multiline/powerline-multiline.theme.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 4f4f8917..a62a7060 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -51,6 +51,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" +HOST_THEME_PROMPT_COLOR=0 + POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} From b1dbf2f7e095fcbbba8cfc712ab1ca9d3402b739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Rogo=C5=BCa?= Date: Sat, 14 Apr 2018 00:49:20 +0200 Subject: [PATCH 4/7] Added additional parameter for bash-it: reload Added creating an alias if command does not exist --- bash_it.sh | 18 +++++++++--------- completion/available/bash-it.completion.bash | 4 ++-- lib/additionals.bash | 16 ++++++++++++++++ lib/helpers.bash | 7 +++++-- 4 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 lib/additionals.bash diff --git a/bash_it.sh b/bash_it.sh index 6e87100d..6b4be1b5 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash # Initialize Bash It -# Reload Library -case $OSTYPE in - darwin*) - alias reload='source ~/.bash_profile' - ;; - *) - alias reload='source ~/.bashrc' - ;; -esac +# Reload Library, replaced by lib/additionals.bash +# case $OSTYPE in +# darwin*) +# alias reload='source ~/.bash_profile' +# ;; +# *) +# alias reload='source ~/.bashrc' +# ;; +# esac # Only set $BASH_IT if it's not already set if [ -z "$BASH_IT" ]; diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 20a94e5b..914c81b7 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -65,7 +65,7 @@ _bash-it-comp() prev="${COMP_WORDS[COMP_CWORD-1]}" chose_opt="${COMP_WORDS[1]}" file_type="${COMP_WORDS[2]}" - opts="disable enable help migrate search show update version" + opts="disable enable help migrate search show update version reload" case "${chose_opt}" in show) local show_args="aliases completions plugins" @@ -82,7 +82,7 @@ _bash-it-comp() return 0 fi ;; - update | search | migrate | version) + update | search | migrate | version | reload) return 0 ;; enable | disable) diff --git a/lib/additionals.bash b/lib/additionals.bash new file mode 100644 index 00000000..f44c017a --- /dev/null +++ b/lib/additionals.bash @@ -0,0 +1,16 @@ +_bash-it-additional-reload() { + _about 'reloads ~/.bashrc' + + case $OSTYPE in + darwin*) + source ~/.bash_profile + ;; + *) + source ~/.bashrc + ;; + esac +} + +if ! command -v reload 1>/dev/null; then + alias reload=_bash-it-additional-reload +fi diff --git a/lib/helpers.bash b/lib/helpers.bash index 9693ea1a..658ffd0e 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -96,8 +96,7 @@ bash-it () version) func=_bash-it-version;; *) - reference bash-it - return;; + func=_bash-it-additional-$verb $component "$@" esac # pluralize component if necessary @@ -107,6 +106,10 @@ bash-it () else if _is_function ${func}es; then func=${func}es + elif [[ $func =~ ^_bash-it-additional- ]]; then + echo "oops! $verb is not valid additional command" + reference bash-it + return else echo "oops! $component is not a valid option!" reference bash-it From 89d1661d2393cee0a2b9af33b14aae99b2098fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Rogo=C5=BCa?= Date: Tue, 17 Apr 2018 23:48:33 +0200 Subject: [PATCH 5/7] Replaced reload section with proper function. Added completion for reload. Fixed order in completion Added unit tests for completion The variable BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE has to be unset. --- bash_it.sh | 10 ------- completion/available/bash-it.completion.bash | 4 +-- lib/additionals.bash | 16 ----------- lib/composure.bash | 2 +- lib/helpers.bash | 28 +++++++++++++++----- test/completion/bash-it.completion.bats | 12 ++++----- test/lib/composure.bats | 2 +- test/test_helper.bash | 1 + 8 files changed, 33 insertions(+), 42 deletions(-) delete mode 100644 lib/additionals.bash diff --git a/bash_it.sh b/bash_it.sh index 6b4be1b5..d85579a4 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -1,16 +1,6 @@ #!/usr/bin/env bash # Initialize Bash It -# Reload Library, replaced by lib/additionals.bash -# case $OSTYPE in -# darwin*) -# alias reload='source ~/.bash_profile' -# ;; -# *) -# alias reload='source ~/.bashrc' -# ;; -# esac - # Only set $BASH_IT if it's not already set if [ -z "$BASH_IT" ]; then diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 914c81b7..71ec8418 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -65,7 +65,7 @@ _bash-it-comp() prev="${COMP_WORDS[COMP_CWORD-1]}" chose_opt="${COMP_WORDS[1]}" file_type="${COMP_WORDS[2]}" - opts="disable enable help migrate search show update version reload" + opts="disable enable help migrate reload search show update version" case "${chose_opt}" in show) local show_args="aliases completions plugins" @@ -82,7 +82,7 @@ _bash-it-comp() return 0 fi ;; - update | search | migrate | version | reload) + migrate | reload | search | update | version) return 0 ;; enable | disable) diff --git a/lib/additionals.bash b/lib/additionals.bash deleted file mode 100644 index f44c017a..00000000 --- a/lib/additionals.bash +++ /dev/null @@ -1,16 +0,0 @@ -_bash-it-additional-reload() { - _about 'reloads ~/.bashrc' - - case $OSTYPE in - darwin*) - source ~/.bash_profile - ;; - *) - source ~/.bashrc - ;; - esac -} - -if ! command -v reload 1>/dev/null; then - alias reload=_bash-it-additional-reload -fi diff --git a/lib/composure.bash b/lib/composure.bash index 5ef7104c..c05f8ed0 100644 --- a/lib/composure.bash +++ b/lib/composure.bash @@ -10,7 +10,7 @@ composure_keywords () { - echo "about author example group param version" + echo "about author example group param reload version" } letterpress () diff --git a/lib/helpers.bash b/lib/helpers.bash index 658ffd0e..e80c8459 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -61,7 +61,7 @@ function reload_plugins() { bash-it () { about 'Bash-it help and maintenance' - param '1: verb [one of: help | show | enable | disable | migrateĀ | update | search | version ] ' + param '1: verb [one of: help | show | enable | disable | migrateĀ | update | search | version | reload ] ' param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)' param '3: specific component [optional]' example '$ bash-it show plugins' @@ -72,6 +72,7 @@ bash-it () example '$ bash-it update' example '$ bash-it search ruby [[-]rake]... [--enable | --disable]' example '$ bash-it version' + example '$ bash-it reload' typeset verb=${1:-} shift typeset component=${1:-} @@ -95,8 +96,11 @@ bash-it () func=_bash-it-migrate;; version) func=_bash-it-version;; + reload) + func=_bash-it-reload;; *) - func=_bash-it-additional-$verb $component "$@" + reference bash-it + return;; esac # pluralize component if necessary @@ -106,10 +110,6 @@ bash-it () else if _is_function ${func}es; then func=${func}es - elif [[ $func =~ ^_bash-it-additional- ]]; then - echo "oops! $verb is not valid additional command" - reference bash-it - return else echo "oops! $component is not a valid option!" reference bash-it @@ -256,6 +256,22 @@ _bash-it-version() { cd - &> /dev/null || return } +_bash-it-reload() { + _about 'reloads a profile file' + _group 'lib' + + cd "${BASH_IT}" || return + + case $OSTYPE in + darwin*) + source ~/.bash_profile + ;; + *) + source ~/.bashrc + ;; + esac +} + _bash-it-describe () { _about 'summarizes available bash_it components' diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index 3cdc84ba..f35b180b 100644 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -99,32 +99,32 @@ function __check_completion () { @test "completion bash-it: show options" { run __check_completion 'bash-it ' - assert_line -n 0 "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate reload search show update version" } @test "completion bash-it: bash-ti - show options" { run __check_completion 'bash-ti ' - assert_line -n 0 "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate reload search show update version" } @test "completion bash-it: shit - show options" { run __check_completion 'shit ' - assert_line -n 0 "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate reload search show update version" } @test "completion bash-it: bashit - show options" { run __check_completion 'bashit ' - assert_line -n 0 "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate reload search show update version" } @test "completion bash-it: batshit - show options" { run __check_completion 'batshit ' - assert_line -n 0 "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate reload search show update version" } @test "completion bash-it: bash_it - show options" { run __check_completion 'bash_it ' - assert_line -n 0 "disable enable help migrate search show update version" + assert_line -n 0 "disable enable help migrate reload search show update version" } @test "completion bash-it: show - show options" { diff --git a/test/lib/composure.bats b/test/lib/composure.bats index af4bc8cf..7ba88853 100755 --- a/test/lib/composure.bats +++ b/test/lib/composure.bats @@ -5,5 +5,5 @@ load ../../lib/composure @test "lib composure: composure_keywords()" { run composure_keywords - assert_output "about author example group param version" + assert_output "about author example group param reload version" } diff --git a/test/test_helper.bash b/test/test_helper.bash index e2bb9442..9784cdf8 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -4,6 +4,7 @@ unset NGINX_PATH unset IRC_CLIENT unset TODO unset SCM_CHECK +unset BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE BASH_IT_TEST_DIR="${BATS_TMPDIR}/.bash_it" From 48e6888a38eb30935318e3a458c76175bc058f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Rogo=C5=BCa?= Date: Sat, 21 Apr 2018 19:15:50 +0200 Subject: [PATCH 6/7] Removed reload keyword from composure_keywords(), it is not needed --- lib/composure.bash | 2 +- test/lib/composure.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/composure.bash b/lib/composure.bash index c05f8ed0..5ef7104c 100644 --- a/lib/composure.bash +++ b/lib/composure.bash @@ -10,7 +10,7 @@ composure_keywords () { - echo "about author example group param reload version" + echo "about author example group param version" } letterpress () diff --git a/test/lib/composure.bats b/test/lib/composure.bats index 7ba88853..af4bc8cf 100755 --- a/test/lib/composure.bats +++ b/test/lib/composure.bats @@ -5,5 +5,5 @@ load ../../lib/composure @test "lib composure: composure_keywords()" { run composure_keywords - assert_output "about author example group param reload version" + assert_output "about author example group param version" } From b288ecbd2752ebbf2c56852f969658abb0dc7c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Rogo=C5=BCa?= Date: Wed, 25 Apr 2018 19:53:06 +0200 Subject: [PATCH 7/7] Added legacy alias reload: https://github.com/Bash-it/bash-it/issues/1120#issuecomment-354376835 --- bash_it.sh | 12 ++++++++++++ template/bash_profile.template.bash | 3 +++ 2 files changed, 15 insertions(+) diff --git a/bash_it.sh b/bash_it.sh index d85579a4..2d085e9d 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -102,5 +102,17 @@ then . "$HOME/.jekyllconfig" fi +# BASH_IT_RELOAD_LEGACY is set. +if ! command -v reload &>/dev/null && [ -n "$BASH_IT_RELOAD_LEGACY" ]; then + case $OSTYPE in + darwin*) + alias reload='source ~/.bash_profile' + ;; + *) + alias reload='source ~/.bashrc' + ;; + esac +fi + # Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040 set +T diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index a052e91e..01097960 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -48,5 +48,8 @@ export SCM_CHECK=true # after enabling or disabling aliases, plugins, and completions. # export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1 +# Uncomment this to make Bash-it create alias reload. +# export BASH_IT_RELOAD_LEGACY=1 + # Load Bash It source "$BASH_IT"/bash_it.sh