If you're a fan of shell scripts in macOS, you've probably noticed that you continue with an unusable terminal window after running. You can fix this in the terminal settings.
This method works only if you start a shell script outside of bash, such as For example, click on it in the Finder or set a custom hotkey to open the program. Otherwise, you will simply be returned to the command prompt. You can always use
killall Terminal to close the terminal app within a script, but this will close any open terminal window, so it's not ideal.
Change this behavior in the profile settings [1
9659005] Open the Terminal App from the Applications Dock or Applications folder and open the Preferences by pressing Command + Comma.
In the Settings window, go to the Profiles tab. The default profile (the top profile) should be selected by default. In the settings on the right, click the "Shell" tab, and then click the "When Shell Ends" drop-down menu.
The drop-down menu defaults to "Close the." Window ", but you want to change this to" Close when the shell finishes clean ".
You can also close it every time, but it does. This will still give you an error message when a process finishes with a nonzero exit status becomes. Remember, you may need to explicitly exit the script with the command
exit to preserve this behavior in all cases.
Although you & # 39; When you exit the Finder, the exit command is automatically appended to the script.
Script is ending. If you're already using iTerm as your default terminal, you may have noticed that Finder-initiated shell scripts are still being opened with the default Terminal App. This means that you still have the same problem unless you have specified that scripts should be opened with iTerm.
You can change which application scripts you right-click on the script in the Finder and then choose Get Info.
There will be a drop down menu to change what is opened with this script. Set the setting to iTerm and press "Change All" to apply this change to each script.
If you already have an iTerm window open, it will be opened by default in a separate window and not in a separate window. Close automatically when it's done.