You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Filtering processes is currently very limited, where you can just type a string literal that seemingly gets matched against the entire "line" of process text (command, arguments, user, etc). One common use case I have is wanting to filter by both user, and process name. There doesn't seem to be any way to do this. Another use case might be wanting to filtering by part of the process name, but also one of the argument names - and so on.
It seems like this issue has been suggested and upvoted considerably in the past, and there was even a PR for it, from a number of years ago.
Describe the solution you'd like
I can see a few possible solutions here, some of which can be combined:
regex
A sort of "fzf" (with --exact) like search. The core idea is very simple: you give multiple terms separated by space, and you filter down to processes that contain all the terms, in any order. So simply searching nir foo will find processes that contain "nir", and "foo", anywhere. This would in practice let me quickly filter processes that have nir as the user and foo as the process name. This idea can be simply extended by treating a leading ! of a group as negation. Spaces are either disallowed from search, or you'd have to escape them or quote them (not sure how useful spaces are anyhow in this context).
fielded search. This combines with either of the other two options, but especially naturally with 2. You allow things of the form u:nir foo, which allows searching for processes that contain nir for the user and foo anywhere. While this is cool, I don't actually personally think this is worth it, as this doesn't solve some issues that 1-2 solve, and 1-2 solves the fielded search problem "well enough" in practice.
Personally, I suggest just implementing 2 with negation, without worrying about escaping spaces. This solves the problem, it's extremely easy to implement, it's more intuitive and easier than regex (worrying about which flavor of regex). It's also agnostic to the "order" of the various text fields of a process. If you go with regex, we still have to consider whether the appropriate search will be nir.*foo or foo.*nir.
If we can agree on the design then I'm willing to try to take a look at the code and make a PR.
The text was updated successfully, but these errors were encountered:
@imwints Thanks for making me aware of that! Unfortunately, as far as I can see this does not solve the use case I mentioned. Since the regex is matched against every field individually (rather than e.g. against some kind of concatenated string), this doesn't really let me even try to filter processes by both name and user simultaneously. Given that the ! and regex approach is already present, would you be willing to consider something like 3?
nir foo // same as present; a search for "nir foo" including the space, in any field of the process
!nir.*foo // same as present; regex search in any field of the process
u:nir foo // searches nir in user, foo in any field
u:nir !bar.*foo // searches nir in user, and the regex bar.*foo in any field
u:nir bar foo // searches nir in user, "bar foo" in any field - space is still permitted
u:!(nir|john) bar foo // allows regex search in user too
The only kind of weird case in this is if users do something like foo u:nir bar; it's a little weird how to interpret this so maybe it would be ideal to just error here?
Another option, if you're willing, is for me to implement 2, but make it opt in via user-config - thoughts? This would actually probably be my personal preference.
Is your feature request related to a problem? Please describe.
Filtering processes is currently very limited, where you can just type a string literal that seemingly gets matched against the entire "line" of process text (command, arguments, user, etc). One common use case I have is wanting to filter by both user, and process name. There doesn't seem to be any way to do this. Another use case might be wanting to filtering by part of the process name, but also one of the argument names - and so on.
It seems like this issue has been suggested and upvoted considerably in the past, and there was even a PR for it, from a number of years ago.
Describe the solution you'd like
I can see a few possible solutions here, some of which can be combined:
nir foo
will find processes that contain "nir", and "foo", anywhere. This would in practice let me quickly filter processes that have nir as the user and foo as the process name. This idea can be simply extended by treating a leading ! of a group as negation. Spaces are either disallowed from search, or you'd have to escape them or quote them (not sure how useful spaces are anyhow in this context).u:nir foo
, which allows searching for processes that containnir
for the user andfoo
anywhere. While this is cool, I don't actually personally think this is worth it, as this doesn't solve some issues that 1-2 solve, and 1-2 solves the fielded search problem "well enough" in practice.Personally, I suggest just implementing 2 with negation, without worrying about escaping spaces. This solves the problem, it's extremely easy to implement, it's more intuitive and easier than regex (worrying about which flavor of regex). It's also agnostic to the "order" of the various text fields of a process. If you go with regex, we still have to consider whether the appropriate search will be
nir.*foo
orfoo.*nir
.If we can agree on the design then I'm willing to try to take a look at the code and make a PR.
The text was updated successfully, but these errors were encountered: