Add autoenv reload subcommand

The `autoenv reload` subcommand reloads the current environment.
This commit is contained in:
Kenneth Benzie 2021-02-09 16:45:52 +00:00
parent 0b5fc5ad97
commit c4a91481db
2 changed files with 13 additions and 1 deletions

View File

@ -16,6 +16,7 @@ _autoenv() {
init:'add .enter and .exit scripts in current directory'
edit:'edit .enter and .exit scripts in current directory'
deinit:'remove .enter and .exit scripts in current directory'
reload:'reload the current environment'
add=py:'add Python virtualenv to the autoenv'
)
_describe -t commands command commands && ret=0 ;;

View File

@ -12,7 +12,7 @@ autoenv() {
case "$cmd" in
-h|--help) # Display help.
echo "\
usage: autoenv [-h] {init,edit,deinit}
usage: autoenv [-h] {init,edit,deinit,reload,add=py}
options:
-h, --help show this help message and exit
@ -21,6 +21,7 @@ commands:
init add .enter and .exit scripts in current directory
edit edit .enter and .exit scripts in current directory
deinit remove .enter and .exit scripts in current directory
reload reload the current environment
add=py add Python virtualenv to the autoenv"
;;
@ -81,6 +82,16 @@ commands:
done
;;
reload) # Reload the current environment
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
echo '.enter or .exit not found'; return 1
fi
# Exit the autoenv before editing.
_autoenv_exit $PWD
# Enter the autoenv.
_autoenv_enter $PWD
;;
add=py) # Add Python virtualenv to the sandbox
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
echo '.enter or .exit not found'; return 1