On Thu, 9 Apr 2026 14:26:51 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.
>> 
>> ---------
>> - [ ] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Ivan Bereziuk has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains eight additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into 8357439_bash_autocomplete_for_jcmd
>  - copy the autocompletion script to the jdk image
>  - move script in bash-completion/ folder and remove extention
>  - moved the script from man to conf folder
>  - declare functions consistently
>  - more clenup
>  - copyright header. minor cleanup
>  - 8357439: add bash autocompletion for jcmd

src/jdk.jcmd/share/conf/bash-completion/jcmd line 1:

> 1: #!/usr/bin/env bash

Needed?
On my system, I see hundreds of files in /usr/share/bash-completion/completions 
and 2 with this line, so it might be there by mistake.  Are the instructions to 
"source" this file, not run it directly?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30606#discussion_r3063286563

Reply via email to