Merge branch '3-autoattach-is-not-case-insentive-for-y' into 'master'

Resolve "autoattach is not case insentive for 'Y'"

Closes #3

See merge request lhprojects-information-network/scripts!3
This commit is contained in:
Lutchy Horace 2021-02-10 15:21:04 -05:00
commit c0a0c8c1ff
1 changed files with 16 additions and 14 deletions

View File

@ -41,21 +41,23 @@ function attach_session
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "There is no tmux session '$1'" echo "There is no tmux session '$1'"
if [ -z "${AUTO_CREATE}" ]; then if [ -z "${AUTO_CREATE}" ]; then
read -p "Do you want me to auto create sessions by default? [Y/n]: " read -p "Do you want me to auto create sessions by default? [Y/n]: "
if [ "${REPLY}" = "y" -o -z "${REPLY}" ]; then # convert to lowercase, then match
write_setting 'AUTO_CREATE' '1' if [ "${REPLY,,}" = "y" -o -z "${REPLY}" ]; then
AUTO_CREATE=1 write_setting 'AUTO_CREATE' '1'
else AUTO_CREATE=1
write_setting 'AUTO_CREATE' '0' else
fi write_setting 'AUTO_CREATE' '0'
fi fi
fi
if [ "${AUTO_CREATE}" = "1" ]; then if [ "${AUTO_CREATE}" = "1" ]; then
tmux new-session -s $1 2> /dev/null tmux new-session -s $1 2> /dev/null
exit 0 exit 0
fi fi
echo 'Nothing to do, exiting...'
exit 1 echo 'Nothing to do, exiting...'
exit 1
fi fi
} }