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
Introduce feature to search for processes #216
Conversation
Hi @cr-mitmit ! I love how thorough you were with this PR, even updating the printed help and the readme! Unfortunately, and I'll be upfront, this one is gonna be tricky! If you can tackle both, then this just might be merged (eventually). Also, may I ask which use cases you see this being useful for? |
Hi. Re preview, the flags I use are The default table shows the pid and the full command line (including arguments). Would love your thoughts |
Great! Let's keep the cross-OS compatibility in mind. Also, let's be sure to include Cygwin.
Yeah definitely being able to see the parent pid and command would be helpful. Maybe start time as well? TBH I'm not sure. That's why I'd like to explore this topic more by re-asking this question: "may I ask which use cases you see this being useful for?" Personally, I've never had to kill a process using the commandline so I have no intuition as to what users will need. |
Hi. I'll look into adding the preview including the parent information. |
Also added a preview. As far as I can tell uses only portable flags across both Linux, WSL and Macos |
Hmm that's tough. @kidonng sorry to bother you. Do you have Windows experience to help out here? |
Nice! I think we're very close. The last thing I'd like to see if if we can show the username instead of uid in the preview. Is that possible and portable? Reason: I noticed that Mac's Activity Monitor shows username in all of its windows and so it seems to be a pretty important thing to know, and users don't want to have to deal with ids. |
@@ -12,6 +12,7 @@ DESCRIPTION | |||
Search git status | Ctrl+Alt+S (S for status) | --git_status | |||
Search history | Ctrl+R (R for reverse) | --history | |||
Search variables | Ctrl+V (V for variable) | --variables | |||
Search processes | Ctrl+O (O for prOcess) | --pids |
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.
this says 0 but you got it bought to o. which one do you think is best?
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.
Might it be a font issue? I've verified again all letters are O (capital o) and not Zero
The binding is done to \co to mimic the way Ctrl-R is bound to \cr (and since Ctrl binding are case insensitive).
Therefore, Ctrl-O is bound to the Process list.
Am I missing something?
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.
Oops my bad it is a capital o indeed. Ok I think that's fine...
Btw can you make the option --processes instead of --pids?
Also added the -O user to add the user-name to the process list. Good idea |
Can you put -O user so it comes first in the output? |
Changed the command to user processes instead of pids (Not just the doc, across the commit). As for where the user listing appears, the only way to specific the order explicitly is to forgo the |
Good point. I will take it upon myself to figure out the set of portable options and figure out the best one to use from here. As the plugin author, I need to worry about having a sane set of defaults and portability so I'll need to do this anyway. Please wait patiently as I have a lot of real work to catch up on returning from vacation, but rest assured I should get this in within a week. Thanks for opening up this PR and your hard work so far! |
Also I think you might've forgotten to push this commit. |
Pushed. Sorry |
Todos for myself (feel free to chime in with your feedback)
|
Sounds great. |
I've implemented a new preview, but getting memory into M and G (as opposed to KB which is what PS returns) is ugly as hell. It's ugly as hell... but works...
|
What if you just returned the memory and CPU as percentages? It’s already
built in
…On Fri, Jan 7, 2022 at 9:25 AM cr-mitmit ***@***.***> wrote:
I've implemented a new preview, but getting memory into M and G (as
opposed to KB which is what PS returns) is ugly as hell.
Any thoughts on how to make this preview bearable?
Technically, it sets the PS, converts the RSS number into strings with M
and G depending on the memory usage and the painfully recreates a table and
accounting for processes whose name contains a space (so all "columns"
after the 6th are actually fake because of spaces in the command line).
It's ugly as hell... but works...
--preview='ps -o pid,user,%cpu,time,rss,command -p {1} | awk \'NR>1 {if ($5 > 1048576) {$5=sprintf("%.02fG", $5/1024/1024);} else {$5=sprintf("%.02fM",$5/1024);}}{for(i=1;i<=5;i++){printf("%s|", $i); $i=""}; $0=$0; print; }\' | column -s"|" -t' \
—
Reply to this email directly, view it on GitHub
<#216 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPAJEE6CXE7SHV3T5LWWODUU4O2FANCNFSM5LANTWAA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID: <PatrickF1/fzf.
***@***.***>
|
I find it less usable. I'll push the change that shows pid, user, %cpu, ram, command line with the awk based printing. Let me know what you think. Also, I experimented with adding the user to the main table, but found that it takes too much screen real-estate. |
functions/_fzf_search_processes.fish
Outdated
--header-lines=1 \ | ||
--preview='ps -o pid,user,%cpu,time,rss,command -p {1}' \ | ||
$fzf_arguments | \ | ||
awk '{print $1}' |
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.
how come you still need awk?
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.
Good point. The output from FZF is the entire line, but I'm trying to extract just the PID here to be useful for commands such as "kill". the awk
here is simply extracting the pid from the selected line
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.
Ah so we want to reduce dependencies so you could just use standard fish functions to do this. Check out how I did it in _fzf_search_git_log
Don't worry I haven't forgotten about this! I will try to take another pass at it today. We are close! |
Hi. Any news? |
Hi @cr-mitmit. I am so sorry. I'm honestly pretty behind on life but this is still important to me and still high up on my to do list (except other things keep getting added on top if it as fast as I can complete them). If you'd like to speed it up, you could try to tackle one of my last todos:
|
|
||
if test $status -eq 0 | ||
set pid_selected (string split -n " " $process_selected)[1] | ||
commandline --current-token --replace -- (string escape -- $pid_selected) |
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.
found a bug: this works for one process but not multiple. probably should be doing $process_selected)[1]
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.
also, is string escape necessary?
…ery and type out full flag
rss and vsz too confusing and do not match with Activity Monitor's data anyway. Plus we can change this easily without worrying about backwards compatibility
According to https://manpages.ubuntu.com/manpages/xenial/man1/ps.1.html, %mem is simply rss over physical memory on the machine so I changed it back for the reasons you gave before. |
Ok sorry for the delay. I decided to just merge this in so you don't have to wait any longer and just implement the other changes I want by myself. Sorry it took so long--besides being very busy, I am also a bit of a perfectionist. |
Thank you - for the merge as well as writing fzf.fish! |
You're welcome! I'm spurred on by everyone who contributes and uses it! :) |
Allows searching for PIDs of any running process.
Useful for commands such as
Todos
add process owner to main fzf window: CANCELLED not enough space