From c21ce7a2980b0d6218812018a3ac5ac72ab95e50 Mon Sep 17 00:00:00 2001 From: Aaqif Shafi Date: Wed, 1 Oct 2025 19:28:51 +0530 Subject: [PATCH] Added Kill Processes Running od specific ports --- commands/system/kill-a-process-on-port.sh | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 commands/system/kill-a-process-on-port.sh diff --git a/commands/system/kill-a-process-on-port.sh b/commands/system/kill-a-process-on-port.sh new file mode 100755 index 000000000..c97f38f87 --- /dev/null +++ b/commands/system/kill-a-process-on-port.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Required parameters: +# @raycast.schemaVersion 1 +# @raycast.title Kill a process on PORT +# @raycast.mode compact + +# Optional parameters: +# @raycast.icon 🚫 +# @raycast.argument1 { "type": "text", "placeholder": "Ports (e.g. 3000 5000)" } + +# Documentation: +# @raycast.description Kill running processes on the given ports +# @raycast.author aaqifshafi +# @raycast.authorURL https://github.com/aaqifshafi + +if [ $# -eq 0 ]; then + echo "Provide at least one port number." + exit 1 +fi + +for port in "$@" +do + pid=$(lsof -ti tcp:$port) + if [ -n "$pid" ]; then + kill -9 $pid + echo "Killed process $pid on port $port" + else + echo "No process found on port $port" + fi +done