xenodium · 2022-11-13 01:14
xenodium · 2022-11-13 01:15
An interactive function to fuzzy search and kill processes: https://xenodium.com/emacs-quick-kill-process
kamui78 · 2022-11-13 01:54
Super useful!! Thanks!!
[deleted] · 2022-11-13 02:11
[deleted]
xenodium · 2022-11-13 02:12
Hey, nice to hear. Thanks!
kamui78 · 2022-11-13 02:15
I now have this function in my i3 config under the Ctrl-Space k shortcut. This way I can kill a process from everywhere, even when I am not in Emacs directly. I actually wanted to write something like this for a while but kept postponing. Your function solves my issue. Thanks again!
MrMelankoli · 2022-11-13 13:32
Is this Emacs in terminal mode and not GUI?
xenodium · 2022-11-13 13:51
GUI, but should work with terminal too.
arthurno1 · 2022-11-13 15:09
That looks very nice indeed.
If you can live without some fancy looks, this one does a similar job, but is slightly simpler, and doesn't require proced, nor any other library:
(defun my-kill-process ()
(interactive)
(let* ((processes
(remove-if-not
(lambda (name)
(and (stringp name)
(not (string-match-p "root" name))
(string-match-p
(user-login-name) name)))
(split-string
(shell-command-to-string "ps -aux") "\n" t)))
(process (completing-read "Kill: " processes nil t)))
(shell-command-to-string (concat "kill -9 " (nth 1 (split-string process))))))
I only do processes owned by my username here, so I skip sudo handling here. It is actually really rare that I need to kill a process, so I am fine with that. Output of last command is also ignored on purpose.
IcePhoneX_ · 2022-11-13 16:50
Can you kill emacs from emacs though
xenodium · 2022-11-13 16:58
You try 🙃
gxonatano_ · 2022-11-13 22:13
Only problem is that 95% of all the processes I ever need to kill are emacs.