-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce feature to search for processes (#216)
Useful for commands such as kill -STOP $pid or lsof -p $pid Includes a preview that shows other useful information about the process selected such as parent pid, CPU use, memory use, and start time. There will be a follow up commit to this one to clean up the code, add tests, add a gif, and enable fzf multi-select. I'm merging this in early because the PR has been open for far too long and is already in a usable, tested state.
- Loading branch information
Showing
5 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function _fzf_search_processes --description "Search all running processes. Replace the current token with the pid of the selected process." | ||
set token (commandline --current-token) | ||
|
||
set process_selected ( | ||
ps -A -opid,command | \ | ||
_fzf_wrapper --query "$token" \ | ||
--ansi \ | ||
--header-lines=1 \ | ||
--preview='ps -o pid,user,ppid,%cpu,rss,time,start,command -p {1}' \ | ||
$fzf_processes_opts | ||
) | ||
|
||
if test $status -eq 0 | ||
set pid_selected (string split --no-empty " " $process_selected)[1] | ||
commandline --current-token --replace -- (string escape -- $pid_selected) | ||
end | ||
|
||
commandline --function repaint | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters