After a long day of hard work I endup having many apps open. Xcode, Visual Studio Code, Simulators, the terminal... when it's six o'clock I want to close everything work related instantaneously whiteout effort.
This is one of the simplest but most used little tools I have in my computer. A script that kills all applications. To have your own version just make an
sh file and add the following:
killallfor most applications
In macOS you can use
killall followed by the name of an application to kill all its related processes.
pgrepfor other binaries
kill -9 $(pgrep Electron) # Visual Studio Code
For some applications, the app name doesn't correspond directly with the process identifier so it's a little harder to kill.
For those pesky ones use
kill -9 $(pgrep NAME) to find the process id of the app and kill that process.
I personally like to finish it with a little message and also killing the terminal to keep everything clean:
echo "Go home now..." killall Terminal
Now you just need to put this script in
/usr/local/bin and name it however you want (mine is called
six because I run it at 6 O'Clock).
Now when is time to stop working you can run that command from the terminal and go home.