From 934b0f46b721949a3a1e7fe55934d840b69d4ed0 Mon Sep 17 00:00:00 2001 From: Andrew Janssen Date: Fri, 8 Nov 2024 07:47:54 -0800 Subject: [PATCH 1/2] Search processes with comma-separated queries, incl regexes --- src/routes/+page.svelte | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 5a8c565..169237a 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -60,11 +60,22 @@ }; $: filteredProcesses = processes.filter((process) => { - const matchesSearch = searchTerm - ? process.name.toLowerCase().includes(searchTerm.toLowerCase()) || - process.command.toLowerCase().includes(searchTerm.toLowerCase()) || - process.pid.toString().includes(searchTerm) - : true; + let matchesSearch = searchTerm.length === 0; + searchTerm + .split(",") + .map((term) => term.trim()) + .forEach((term) => { + const nameSubstringMatch = process.name + .toLowerCase() + .includes(term.toLowerCase()); + const nameRegexMatch = new RegExp(term, "i").test(process.name); + const commandMatch = process.command + .toLowerCase() + .includes(term.toLowerCase()); + const pidMatch = process.pid.toString().includes(term); + matchesSearch ||= + nameSubstringMatch || nameRegexMatch || commandMatch || pidMatch; + }); const matchesStatus = statusFilter === "all" ? true : process.status === statusFilter; From 360b09be221c45260ee7dbda6bf9e005f85e8cd0 Mon Sep 17 00:00:00 2001 From: Andrew Janssen Date: Fri, 8 Nov 2024 08:16:49 -0800 Subject: [PATCH 2/2] Update README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f7cefd8..051a6a8 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ - 💻 CPU and Memory usage tracking - 🎨 Beautiful, modern UI with dark/light themes - 🔍 Process search and filtering + + Search for processes by name, command, or PID. Search for multiple things at once by separating them with commas. For + example, `arm, x86` will return processes having `arm` or `x86` as a substring of the name or command. You can use + regular expressions too. For example, `d$` will return a list of daemons (which tend to end in the letter `d`), while + `(\w+)\.\w+` will return a list of processes with reverse domain name notation, such as `com.docker.vmnetd`. + - 📌 Pin important processes - 🛠 Process management (kill processes) - 🎯 Sort by any column