On Tue, 7 Apr 2026 15:35:53 GMT, Ivan Bereziuk <[email protected]> wrote:

> I propose a Bash auto-completion script for the `jcmd` tool. It will simplify 
> the most tedious part of `jcmd` tool usage -selecting <PID|main-class> and 
> the command name.
> 
> To determine auto-completion candidates, the script makes intermediate calls 
> to `jcmd` and then parses the output:
> * `jcmd -l` to retrieve the list of running JVM processes;
> * `jcmd <PID> help` to get the list of available diagnostic commands;
> 
> The "-o nosort" is set to preserve natural ordering of candidates: The 
> resulting order of completion candidates printed, on double-`TAB` is 
> structured:  the JVM identifier (<main-class | path-to-jar>) appears 
> immediately after the corresponding PID, maintaining a clear and meaningful 
> association.
> 
> Example with 2 JVMs running:
> 
> $ jcmd -l
> 91936 jdk.jcmd/sun.tools.jcmd.JCmd -l
> 91668 install/MyApp.jar
> 91769 EventGeneratorLoop 100
> $ jcmd <TAB_key_press>
> -l                  --help              91668               install/MyApp.jar 
>   91769               EventGeneratorLoop
> 
> 
> Overall it should greatly improve QoL for `jcmd` Users.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 8549d189
Author:    Ivan Bereziuk <[email protected]>
Committer: Kevin Walls <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/8549d1896054dd230ba3038c83bce23b10dcda22
Stats:     199 lines in 2 files changed: 199 ins; 0 del; 0 mod

8357439: Add bash autocompletion for jcmd

Reviewed-by: erikj, kevinw

-------------

PR: https://git.openjdk.org/jdk/pull/30606

Reply via email to