How to "killall" Visual Studio Code in Terminal?

I have a small shell script called "k" that i call everytime when i want to reset my complete Development Cycle:

killall node
killall Xcode
killall Terminal

How can i find out the final name of the "Visual Studio Code"-Prozess to kill it also this way?

I've tried:

killall "Visual Studio Code"

No matching processes belonging to you were found

killall "Code"

No matching processes belonging to you were found

Any ideas? I am looking for a generic approach without any manually lookup of PIDs necessary.

This application looks like this in Activity Monitor: enter image description here


Solution 1:

I have Visual Studio Code, version 1.1.1, installed and on my system the following works for me:

kill -9 $(pgrep Electron)

Update: Just tested with Visual Studio Code, version 1.14.1, under macOS 10.12.5 and the above command closes Code and Code Helper that show in Activity Monitor.

PS: killall Electron also works.

Solution 2:

Alternative for Mac OS (Darwin) is:

osascript -e 'quit app "Visual Studio Code"'

Solution 3:

This one is working for me, pkill Electron or pkill Visual Studio Code