Demonstrate use of sessions with bash in org babel.
Get basics about the shell, etc. Set a varable
date echo SHELL is $SHELL echo BASH_VERSION is $BASH_VERSION echo PID is $$ SET_IN_FIRST_BLOCK=something
Wed Nov 16 07:45:29 AM EST 2022 SHELL is /bin/bash BASH_VERSION is 5.1.16(1)-release PID is 73788
Get pid. Should be same as previous example.
See if the variable exists
date echo PID is $$ [[ -v SET_IN_FIRST_BLOCK ]] && \ echo SET_IN_FIRST_BLOCK is $SET_IN_FIRST_BLOCK || \ echo SET_IN_FIRST_BLOCK is not defined
Wed Nov 16 07:45:32 AM EST 2022 PID is 73788 > > SET_IN_FIRST_BLOCK is something
Pay no attention to that man behind the curtain.
This is emacs lisp foo that turn of prompting when killing the buffer running the shell.
(setq kill-buffer-query-functions (remq 'process-kill-buffer-query-function kill-buffer-query-functions))
Kill the TEST session. Variables, PID should reset.
PS1="$ " date echo TEST session killed echo PID is $$ [[ -v SET_IN_FIRST_BLOCK ]] && \ echo SET_IN_FIRST_BLOCK is $SET_IN_FIRST_BLOCK || \ echo SET_IN_FIRST_BLOCK is not defined
gmj@mx:$ Wed Nov 16 07:45:39 AM EST 2022 TEST session killed PID is 73860 gmj@mx:$ > > SET_IN_FIRST_BLOCK is not defined