From 5c139e4567b3ad4e59ff85eb13c0dd8d8dec3115 Mon Sep 17 00:00:00 2001 From: Lutchy Horace Date: Wed, 10 Feb 2021 15:18:24 -0500 Subject: [PATCH] Convert to lowercase, then match. --- autoattach | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/autoattach b/autoattach index 718f2e2..7fb46e9 100755 --- a/autoattach +++ b/autoattach @@ -41,21 +41,23 @@ function attach_session if [ $? -gt 0 ]; then echo "There is no tmux session '$1'" if [ -z "${AUTO_CREATE}" ]; then - read -p "Do you want me to auto create sessions by default? [Y/n]: " - if [ "${REPLY}" = "y" -o -z "${REPLY}" ]; then - write_setting 'AUTO_CREATE' '1' - AUTO_CREATE=1 - else - write_setting 'AUTO_CREATE' '0' - fi - fi + read -p "Do you want me to auto create sessions by default? [Y/n]: " + # convert to lowercase, then match + if [ "${REPLY,,}" = "y" -o -z "${REPLY}" ]; then + write_setting 'AUTO_CREATE' '1' + AUTO_CREATE=1 + else + write_setting 'AUTO_CREATE' '0' + fi + fi - if [ "${AUTO_CREATE}" = "1" ]; then - tmux new-session -s $1 2> /dev/null - exit 0 - fi - echo 'Nothing to do, exiting...' - exit 1 + if [ "${AUTO_CREATE}" = "1" ]; then + tmux new-session -s $1 2> /dev/null + exit 0 + fi + + echo 'Nothing to do, exiting...' + exit 1 fi }