On Fri, 17 Apr 2026 14:02:36 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). > > Ivan Bereziuk has updated the pull request incrementally with one additional > commit since the last revision: > > add comments. fix typos. improve wording One more thing - this is for Linux only? I use Windows and WSL or Cygwin at different times, and I don't think it works properly. On WSL "jcmd.exe" needs to be run, not just "jcmd", not sure if that is the only problem. Cygwin you can run "jcmd" without ".exe" but still doesn't behave as it does on regular Linux. Maybe we should copy the file in place only on Linux? (and if so, that would affect the release note). On the Release Note just thinking again, could be more specific, like: `To enable the autocompletion, at a bash prompt run: 'source <JDK_HOME>/conf/bash-completion/jcmd'. For system-wide...` ...which spells out what to do more clearly. Plus an "on Linux" mention if this is what we are going to do. ------------- PR Comment: https://git.openjdk.org/jdk/pull/30606#issuecomment-4397207601
