I want to open a new tab and open a file using vscode terminal.
like open somefile.js command, so I can use ls and open file quickly.
If you are already in VSCode terminal (not an external OS terminal), check out the latest VSCode 1.64 (Jan. 2022) Terminal shell integration:
The terminal now features experimental opt-in shell integration which allows VS Code to gain insights on what is going on within the terminal as it was previously a black box.
When enabled using "
terminal.integrated.enableShellIntegration": true, arguments to run a shell integration script will be injected into your terminal profile if possible.The script itself mostly just injects invisible sequences into your prompt, providing us with information like where the prompt, command and command output is, what the current working directory (cwd) is for each command and the exit code of each command.
That means:
Link support relative to the cwd
Since we know the
cwdfor each line in the terminal buffer, we can support opening links in the terminal relative to the cwd at the location where it was activated.Before, when a link was clicked, a quick pick would open with results from any folders containing a match for that name.
Now, the exact file match will be opened.
In a terminal with a
cwdof VSCode,package.jsonis echoed.
Clicking on the file name will result invscode/package.jsonopening.The directory is changed to be the
template-string-converterand thenpackage.jsonis echoed.
Clicking on the file name will opentemplate-string-converter/package.json.
startwhatever