Automatically starting genie on every shell session - arkane-systems/genie GitHub Wiki
I use this code at the top of my .zprofile, which prompts me every time I enter wsl (without specifying a particular command; i.e., just wsl alone) to enter the bottle, or not:
# Are we in the bottle?
if [ ! -v INSIDE_GENIE ](/arkane-systems/genie/wiki/-!--v-INSIDE_GENIE-); then
read "yn? * Not inside the genie bottle; enter it?"
if [ ${yn[1]} == "y" ](/arkane-systems/genie/wiki/-${yn[1]}-==-"y"-); then
echo "Starting genie:"
exec /usr/bin/genie -s
fi
fi
If you want to enter the bottle every time, you can replace everything inside the outer if with exec /usr/bin/genie -s. Alternatively, the following:
# Are we in the bottle?
if [ ! -v INSIDE_GENIE ](/arkane-systems/genie/wiki/-!--v-INSIDE_GENIE-); then
read -t 3 -q "yn? * Preparing to enter genie bottle (in 3s); abort? "
echo
if [ $yn != "y" ](/arkane-systems/genie/wiki/-$yn-!=-"y"-); then
echo "Starting genie:"
exec /usr/bin/genie -s
fi
fi
will automatically enter the bottle unless you enter y to abort within three seconds; entering n or waiting for the timeout runs genie.
.bash_profile version
Users having default shell as bash may use this code at the end of .bash_profile, which prompts every time entering wsl (without specifying a particular command; i.e., just wsl alone) to enter the bottle, or not:
# Are we in the bottle?
if [ -z ${INSIDE_GENIE} ](/arkane-systems/genie/wiki/--z-${INSIDE_GENIE}-); then
read -p "yn? * Not inside the genie bottle; enter it? " yn
echo
if [ $yn == "y" ](/arkane-systems/genie/wiki/-$yn-==-"y"-); then
echo "Starting genie:"
exec /usr/bin/genie -s
fi
fi
If you want to enter the bottle every time, you can replace everything inside the outer if with exec /usr/bin/genie -s. Alternatively, the following:
# Are we in the bottle?
if [ -z ${INSIDE_GENIE} ](/arkane-systems/genie/wiki/--z-${INSIDE_GENIE}-); then
read -t 3 -p "yn? * Preparing to enter genie bottle (in 3s); abort? "
echo
if [ $yn != "y" ](/arkane-systems/genie/wiki/-$yn-!=-"y"-); then
echo "Starting genie:"
exec /usr/bin/genie -s
fi
fi
will automatically enter the bottle unless you enter y to abort within three seconds; entering n or waiting for the timeout runs genie.