Added additional parameter for bash-it: reload
Added creating an alias if command does not existpull/1177/head
parent
cd983294ec
commit
b1dbf2f7e0
18
bash_it.sh
18
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" ];
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue