Added additional parameter for bash-it: reload

Added creating an alias if command does not exist
pull/1177/head
Piotr Rogoża 2018-04-14 00:49:20 +02:00
parent cd983294ec
commit b1dbf2f7e0
4 changed files with 32 additions and 13 deletions

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Initialize Bash It # Initialize Bash It
# Reload Library # Reload Library, replaced by lib/additionals.bash
case $OSTYPE in # case $OSTYPE in
darwin*) # darwin*)
alias reload='source ~/.bash_profile' # alias reload='source ~/.bash_profile'
;; # ;;
*) # *)
alias reload='source ~/.bashrc' # alias reload='source ~/.bashrc'
;; # ;;
esac # esac
# Only set $BASH_IT if it's not already set # Only set $BASH_IT if it's not already set
if [ -z "$BASH_IT" ]; if [ -z "$BASH_IT" ];

View File

@ -65,7 +65,7 @@ _bash-it-comp()
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
chose_opt="${COMP_WORDS[1]}" chose_opt="${COMP_WORDS[1]}"
file_type="${COMP_WORDS[2]}" 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 case "${chose_opt}" in
show) show)
local show_args="aliases completions plugins" local show_args="aliases completions plugins"
@ -82,7 +82,7 @@ _bash-it-comp()
return 0 return 0
fi fi
;; ;;
update | search | migrate | version) update | search | migrate | version | reload)
return 0 return 0
;; ;;
enable | disable) enable | disable)

View File

@ -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

View File

@ -96,8 +96,7 @@ bash-it ()
version) version)
func=_bash-it-version;; func=_bash-it-version;;
*) *)
reference bash-it func=_bash-it-additional-$verb $component "$@"
return;;
esac esac
# pluralize component if necessary # pluralize component if necessary
@ -107,6 +106,10 @@ bash-it ()
else else
if _is_function ${func}es; then if _is_function ${func}es; then
func=${func}es func=${func}es
elif [[ $func =~ ^_bash-it-additional- ]]; then
echo "oops! $verb is not valid additional command"
reference bash-it
return
else else
echo "oops! $component is not a valid option!" echo "oops! $component is not a valid option!"
reference bash-it reference bash-it