-
-
Notifications
You must be signed in to change notification settings - Fork 164
Add kill-all option in interactive mode #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,16 +256,25 @@ const listProcesses = async (processes, flags) => { | |
| const cpuThreshold = flags.verbose ? 0 : 3; | ||
| const searcher = new FuzzySearch(processes, ['name'], {caseSensitive: false}); | ||
|
|
||
| const selectedPid = await search({ | ||
| const selectedValue = await search({ | ||
| message: 'Running processes:', | ||
| pageSize: 10, | ||
| async source(term = '') { | ||
| const matchingProcesses = filterAndSortProcesses(processes, term, searcher, flags); | ||
| return matchingProcesses.map(process_ => renderProcessForDisplay(process_, flags, memoryThreshold, cpuThreshold)); | ||
| const choices = matchingProcesses.map(process_ => renderProcessForDisplay(process_, flags, memoryThreshold, cpuThreshold)); | ||
|
|
||
| if (term && matchingProcesses.length > 1) { | ||
| choices.unshift({ | ||
| name: `${chalk.red.bold('Kill all')} ${chalk.dim(`(${matchingProcesses.length} processes matching "${term}")`)}`, | ||
| value: matchingProcesses.map(process_ => process_.pid), | ||
|
Comment on lines
+268
to
+269
|
||
| }); | ||
| } | ||
|
|
||
| return choices; | ||
| }, | ||
| }); | ||
|
|
||
| performKillSequence(selectedPid); | ||
| performKillSequence(selectedValue); | ||
|
||
| }; | ||
|
|
||
| const init = async flags => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing the “Kill all” choice at the top (
unshift) makes it the default/first result for any multi-match search, which increases the chance of accidentally killing all matching processes when the user presses Enter after typing a term. Consider adding an extra confirmation step when this option is chosen, or move it below the individual process results so it’s not the first selectable item.