Compare commits

...

1 Commits

Author SHA1 Message Date
c4a91481db Add autoenv reload subcommand
The `autoenv reload` subcommand reloads the current environment.
2021-02-09 16:47:27 +00:00
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' init:'add .enter and .exit scripts in current directory'
edit:'edit .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' deinit:'remove .enter and .exit scripts in current directory'
reload:'reload the current environment'
add=py:'add Python virtualenv to the autoenv' add=py:'add Python virtualenv to the autoenv'
) )
_describe -t commands command commands && ret=0 ;; _describe -t commands command commands && ret=0 ;;

View File

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