diff --git a/.config/yabai/open-iterm2.sh b/.config/yabai/open-iterm2.sh index 0ea1e260..3a6825e6 100755 --- a/.config/yabai/open-iterm2.sh +++ b/.config/yabai/open-iterm2.sh @@ -6,12 +6,17 @@ # Distributed under terms of the MIT license. # +osascriptcmd='tell application "iTerm2" to create window with default profile' if ! pgrep -f "iTerm" > /dev/null 2>&1; then echo "Opening iTerm" - exec open -a "/Applications/iTerm.app" -elif ! osascript -e 'tell application "iTerm2" to create window with default profile' > /dev/null 2>&1; then + open -a "/Applications/iTerm.app" +fi +if osascript -e "$osascriptcmd" > /dev/null 2>&1; then + echo "Opening new iTerm window" +else echo "Killing iTerm and restarting" killall "iTerm" - exec open -a "/Applications/iTerm.app" + open -a "/Applications/iTerm.app" + osascript -e "$osascriptcmd" fi