Jump to content

Kill Process (PID) by String Program Name


Recommended Posts

Hi all, this is my first workflow. Any feedback is appreciated. Excited to join this community. 🙂

 

Kill Process Alfred Workflow

preview.png

 

Version 1.0.0

 

Alfred Workflow to Kill Process given a string name

 

This Alfred workflow takes a string and searches the currently active processes for the name. It retrieves the corresponding PID for the process and kills it.

This workflow is case-insensitive

 

Usage:

 

- `kill <process-name>`
- `kill pycharm`    - Kills PyCharm Professional
- `kill XCode` - Kills Xcode
- `kil saf` - Kills Safari


Feel free to modify this Workflow in the future 💪🏼
 

GitHub

 

Would anyone know how to add the Workflow to the gallery? Thanks.

Link to comment

Welcome @PopBot,

 

You should be able to simplify the Run Script immensely to essentially a single line: pkill -9 -if "${1}". There’s no need for pgrep as an intermediary as pkill does the job with names. You also don’t need to check if any argument was given, because in the Keyword Input you’re already telling it Argument Required so it won’t work unless the user types something.


Because -9 is quite aggressive, I’d recommend using Alternative Actions to either kill with -15 or -9. That’s up to you, though.

 

13 minutes ago, PopBot said:

Would anyone know how to add the Workflow to the gallery?

 

The process is “pull”, as opposed to “push”.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...