I am running a lot of CLI tools lately and it started to annoy me that every time i run some command group via .command file i have to manually close terminal window. So i came up with this stuff:


echo -n -e "\033]0;Make\007"
osascript -e 'tell application "Terminal" to close (every window whose name contains "Make")' &

lets say this is my make.command file. The problem is that window is closed regardless of the result of the __YOUR__CODE__TO__BE__EXECUTED section. So if i for example run a grunt task or server file upload, i dont really know if it worked or not, does anyone have a suggestion how to adapt the code to make it close terminal but only if there was no error in console?

1 Answer 1


try command

sleep 10 #pause for 10 seconds
  • 2
    although it can be used for like "last resort", it seems like half measure, maybe it can be adjusted so it actually reads the response and somehow verify if its error or not
    – Mevia
    Feb 20, 2018 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .