Add bash-it restart command

Also add completion and completion tests
This commit is contained in:
Noah Gorny
2020-10-12 15:29:36 +03:00
parent 21d094ed5a
commit f4279e63c1
3 changed files with 28 additions and 8 deletions

View File

@@ -45,7 +45,7 @@ alias reload_plugins="$(_make_reload_alias plugin plugins)"
bash-it ()
{
about 'Bash-it help and maintenance'
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload | doctor ] '
param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload | restart | doctor ] '
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'
@@ -57,6 +57,7 @@ bash-it ()
example '$ bash-it search [-|@]term1 [-|@]term2 ... [ -e/--enable ] [ -d/--disable ] [ -r/--refresh ] [ -c/--no-color ]'
example '$ bash-it version'
example '$ bash-it reload'
example '$ bash-it restart'
example '$ bash-it doctor errors|warnings|all'
typeset verb=${1:-}
shift
@@ -84,6 +85,8 @@ bash-it ()
func=_bash-it-migrate;;
version)
func=_bash-it-version;;
restart)
func=_bash-it-restart;;
reload)
func=_bash-it-reload;;
*)
@@ -314,6 +317,23 @@ _bash-it-doctor-() {
_bash-it-doctor-all
}
_bash-it-restart() {
_about 'restarts the shell in order to fully reload it'
_group 'lib'
saved_pwd=$(pwd)
case $OSTYPE in
darwin*)
init_file=.bash_profile
;;
*)
init_file=.bashrc
;;
esac
exec "${0/-/}" --rcfile <(echo "source \"$HOME/$init_file\"; cd \"$saved_pwd\"")
}
_bash-it-reload() {
_about 'reloads a profile file'
_group 'lib'