Skip to content

Instantly share code, notes, and snippets.

@bpetrynski
Last active January 31, 2024 11:42
Show Gist options
  • Save bpetrynski/b624131a3ee09737990b755db9ac9799 to your computer and use it in GitHub Desktop.
Save bpetrynski/b624131a3ee09737990b755db9ac9799 to your computer and use it in GitHub Desktop.
Interactive Process Killer for macOS
ps aux | fzf --header 'Select a process to kill' --preview 'echo {}' | awk '{print $2}' | xargs -I {} kill -9 {}
This one-liner script for macOS provides an interactive way to view and kill processes using the command line. It leverages the power of `ps`, `awk`, `fzf`, and `xargs` to create a user-friendly interface for process management.
When executed, it displays a list of all running processes in an interactive fuzzy finder (`fzf`) interface. Users can search and select a process, which is then terminated using the `kill` command. This script is particularly useful for developers and system administrators who need a quick and efficient way to manage processes without leaving the terminal.
Usage:
- Run the script in the terminal.
- Use the `fzf` interface to search and select a process.
- The selected process will be killed immediately.
Note: This script uses `kill -9` for terminating processes, which forcefully kills the process without saving. Please use it with caution as it can result in unsaved data loss.
Requirements:
- `fzf` needs to be installed on your macOS system.
Disclaimer: This tool should be used responsibly. The author is not responsible for any potential damage or data loss caused by improper use of this script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment