DEV Community

Cover image for psn - a minimalist process navigator for Linux
l5y
l5y

Posted on

psn - a minimalist process navigator for Linux

When a process hangs up on me on a server, my usual workflow is a mix of ps aux | grep, pgrep, copying PIDs, and reaching for kill. It works, but it interrupts my workflows. I decided to go for a little quality-of-life upgrade and implement psn, the process status navigator.

psn is a small Rust TUI. You launch it, find the process, and send it a signal; all without leaving the terminal or typing a PID by hand.

asciicast

The problem it solves

The command-line is where I spend most of my time and earn a living: personal laptops, remote servers, etc. The tooling story for process management is surprisingly fragile. I started to become a power user of btop, my favorite *top-derivate, but kept falling back to ps when I had to deal with processes. However, its output is a wall of text that you have to mentally parse or pipe through grep and then act on with a subsequent command.

The real need is simple: find a process by name and send it a signal. It cannot be so hard? ;)

What it does

psn displays a table of running processes inside a navigatable terminal user interface. Each row of the table shows the process name, PID, user, CPU and memory usage, status, and the full command string. Processes are arranged in a parent–child tree so you can see what spawned what.

From there you can:

  • Navigate with arrow keys up/down and page up/down
  • Collapse and expand subtrees with arrow keys left/right
  • Filter on the fly by pressing / and typing - the list narrows as you type, and matched text is highlighted in the name and command columns
  • Pre-filter at launch by passing a substring (psn cargo) or a regular expression (psn -r '^rust') as an argument
  • Send a signal by pressing 1 through 9; the key maps directly to the Unix signal number - 9 is SIGKILL, 1 is SIGHUP, 2 is SIGINT, and so on

That's it. I didn't ask for more and I also don't think it needs more.

Installation

The fastest path is via crates.io:

cargo install psn
Enter fullscreen mode Exit fullscreen mode

On Arch Linux the psn-bin AUR package installs a prebuilt binary:

yay -S psn-bin
Enter fullscreen mode Exit fullscreen mode

Or build from the GitHub repository directly with cargo build --release. A Nix flake and a Gentoo ebuild are also available.

The only runtime dependency is a GNU/Linux system with procfs support. No ps wrapper, no external binaries - process data is read directly via sysinfo.

If you spend any meaningful time on Linux servers and find yourself reaching for ps | grep | kill more than you'd like, give psn a try. Feedback and issues are welcome!

Top comments (0)