Skip to content
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

Add completion for pstree #10317

Merged
merged 2 commits into from Feb 26, 2024
Merged

Conversation

artemisart
Copy link
Contributor

Description

Add completion for pstree https://www.man7.org/linux/man-pages/man1/pstree.1.html.

Is it possible to show a custom description for each argument value? Here I want to complete PIDs, it would be nice to show the process name in the tab options/search, but only complete with the PID.

pstree help for reference:

Usage: pstree [-acglpsStuZ] [ -h | -H PID ] [ -n | -N type ]
              [ -A | -G | -U ] [ PID | USER ]
       pstree -V
Display a tree of processes.

  -a, --arguments     show command line arguments
  -A, --ascii         use ASCII line drawing characters
  -c, --compact       don't compact identical subtrees
  -h, --highlight-all highlight current process and its ancestors
  -H PID,
  --highlight-pid=PID highlight this process and its ancestors
  -g, --show-pgids    show process group ids; implies -c
  -G, --vt100         use VT100 line drawing characters
  -l, --long          don't truncate long lines
  -n, --numeric-sort  sort output by PID
  -N type,
  --ns-sort=type      sort by namespace type (cgroup, ipc, mnt, net, pid,
                                              user, uts)
  -p, --show-pids     show PIDs; implies -c
  -s, --show-parents  show parents of the selected process
  -S, --ns-changes    show namespace transitions
  -t, --thread-names  show full thread names
  -T, --hide-threads  hide threads, show only processes
  -u, --uid-changes   show uid transitions
  -U, --unicode       use UTF-8 (Unicode) line drawing characters
  -V, --version       display version information
  -Z, --security-context
                      show SELinux security contexts
  PID    start at this PID; default is 1 (init)
  USER   show only trees rooted at processes of this user

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

@faho
Copy link
Member

faho commented Feb 20, 2024

Is it possible to show a custom description for each argument value? Here I want to complete PIDs, it would be nice to show the process name in the tab options/search, but only complete with the PID.

See the completions for kill, which call a function that is made for this called __fish_complete_pids.

What you do is you print the completion candidate followed by a tab and its description, one candidate per line. But in this case you should be able to just call that function.

share/completions/pstree.fish Outdated Show resolved Hide resolved
@artemisart
Copy link
Contributor Author

Thanks @faho ! that's perfect

@artemisart artemisart requested a review from faho February 23, 2024 22:13
@artemisart artemisart changed the title Add completion for pstree.fish Add completion for pstree Feb 26, 2024
@faho faho added this to the fish next-3.x milestone Feb 26, 2024
@faho faho merged commit 73d7605 into fish-shell:master Feb 26, 2024
6 of 7 checks passed
@faho
Copy link
Member

faho commented Feb 26, 2024

Thanks, merged!

@artemisart artemisart deleted the completion/pstree branch March 14, 2024 21:57
@zanchey zanchey modified the milestones: fish next-3.x, fish 3.7.1 Mar 18, 2024
zanchey pushed a commit that referenced this pull request Mar 18, 2024
* Add completion for pstree.fish

* use fish functions, much better

(cherry picked from commit 73d7605)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants