title: VS Code debugging: Is it possible to supply process-id 'pgrep -x "$myprog"' for use in launch.json (variable "processId") when attach to process-id?
body: <p>I noticed that for node.js there's a debugger &quot;auto attach&quot; feature, which I would like to use if it was possible. However, I don't think I can use &quot;auto attach&quot; to automatically fire up the debugger after I've re-compiled my program. I compile my program using C/C++/Fortran using makefiles (and similar) so after running &quot;make&quot; I get a normal (linux) executable. I then execute that binary and often want to debug it right away, after this. I have the full binary path set to an environment variable &quot;$myprog=/home/user/my-dev/bin/myApp&quot;.</p>
  <p>So what I do is to run debug using &quot;Attach to process&quot; and every time I have to find the proper process in the dropdown list, but I do it too many times each day, each hour, it's becoming <em>tedious</em> and would like something smarter, &quot;more automatically&quot;:</p>
  <p>Instead of &quot;auto attach&quot; (only for node.js, as I understand it) I would like to modify my launch.json so it extracts the process-id automatically, using e.g. the shell command: 'pgrep -x &quot;$myprog&quot;' and maybe optionally bind it to a keyboard-shortcut... I'm guessing the line &quot;&quot;processId&quot;: &quot;${command:pickProcess}&quot;,&quot; needs to be modified, please see example configuration below:</p>
  <pre><code> {
              &quot;name&quot;: &quot;(gdb) Attach (any)&quot;,
              &quot;type&quot;: &quot;cppdbg&quot;,
              &quot;request&quot;: &quot;attach&quot;,
              &quot;program&quot;: &quot;/home/user/my-dev/bin/myApp&quot;,
              &quot;processId&quot;: &quot;${command:pickProcess}&quot;,
              &quot;MIMode&quot;: &quot;gdb&quot;,
              &quot;miDebuggerPath&quot;: &quot;/usr/bin/gdb&quot;
          },
  </code></pre>
  <p>Is it possible to modify the launch.json file so VS code understands that the variable &quot;processId&quot; should be substituted by the shell output from: 'pgrep -x &quot;$myprog&quot;' (obviously this PID changes, after every compilation and execution of the program to be debugged)? If so, I guess it is also possible to bind it to a keyboard-shortcut... Anyone knows how to achieve this?</p>