arch-config/.config/fish/functions/_fzf_search_processes.fish
nekochemist fe0aa07f3c deleted: .config/QtProject.conf
deleted:    .config/apps-list.md
	modified:   .config/btop/btop.conf
	deleted:    .config/config.kdl
	new file:   .config/fish/completions/fisher.fish
	new file:   .config/fish/completions/fzf_configure_bindings.fish
	new file:   .config/fish/conf.d/fzf.fish
	new file:   .config/fish/fish_plugins
	modified:   .config/fish/fish_variables
	new file:   .config/fish/functions/_fzf_configure_bindings_help.fish
	new file:   .config/fish/functions/_fzf_extract_var_info.fish
	new file:   .config/fish/functions/_fzf_preview_changed_file.fish
	new file:   .config/fish/functions/_fzf_preview_file.fish
	new file:   .config/fish/functions/_fzf_report_diff_type.fish
	new file:   .config/fish/functions/_fzf_report_file_type.fish
	new file:   .config/fish/functions/_fzf_search_directory.fish
	new file:   .config/fish/functions/_fzf_search_git_log.fish
	new file:   .config/fish/functions/_fzf_search_git_status.fish
	new file:   .config/fish/functions/_fzf_search_history.fish
	new file:   .config/fish/functions/_fzf_search_processes.fish
	new file:   .config/fish/functions/_fzf_search_variables.fish
	new file:   .config/fish/functions/_fzf_wrapper.fish
	new file:   .config/fish/functions/fisher.fish
	new file:   .config/fish/functions/fzf_configure_bindings.fish
	new file:   .config/fish/functions/y.fish
	new file:   .config/fish/functions/yz.fish
	new file:   ".config/fish/functions/\320\275\321\217.fish"
	modified:   .config/kitty/kitty.conf
	modified:   .config/niri/config.kdl
	modified:   .config/nvim/lazy-lock.json
	new file:   .config/nvim/lua/plugins/luasnip.lua
	new file:   .config/nvim/lua/plugins/markview.lua
	new file:   .config/nvim/lua/plugins/marp-nvim.lua
	new file:   .config/nvim/lua/plugins/nvim-snippy.lua
	new file:   .config/nvim/lua/plugins/render-markdown.lua
	deleted:    .config/nwg-look/config
	deleted:    .config/zathura/zathurarc
	modified:   apps-list.md
	new file:   background
	renamed:    .config/mimeapps.list -> mimeapps.list
	renamed:    .config/pavucontrol.ini -> pavucontrol.ini
	deleted:    sing-box-03.json
	renamed:    .config/user-dirs.dirs -> user-dirs.dirs
	renamed:    .config/user-dirs.locale -> user-dirs.locale
2025-11-14 05:38:02 +05:00

32 lines
1.7 KiB
Fish

function _fzf_search_processes --description "Search all running processes. Replace the current token with the pid of the selected process."
# Directly use ps command because it is often aliased to a different command entirely
# or with options that dirty the search results and preview output
set -f ps_cmd (command -v ps || echo "ps")
# use all caps to be consistent with ps default format
# snake_case because ps doesn't seem to allow spaces in the field names
set -f ps_preview_fmt (string join ',' 'pid' 'ppid=PARENT' 'user' '%cpu' 'rss=RSS_IN_KB' 'start=START_TIME' 'command')
set -f processes_selected (
$ps_cmd -A -opid,command | \
_fzf_wrapper --multi \
--prompt="Processes> " \
--query (commandline --current-token) \
--ansi \
# first line outputted by ps is a header, so we need to mark it as so
--header-lines=1 \
# ps uses exit code 1 if the process was not found, in which case show an message explaining so
--preview="$ps_cmd -o '$ps_preview_fmt' -p {1} || echo 'Cannot preview {1} because it exited.'" \
--preview-window="bottom:4:wrap" \
$fzf_processes_opts
)
if test $status -eq 0
for process in $processes_selected
set -f --append pids_selected (string split --no-empty --field=1 -- " " $process)
end
# string join to replace the newlines outputted by string split with spaces
commandline --current-token --replace -- (string join ' ' $pids_selected)
end
commandline --function repaint
end