Reputation: 102547
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.
Upvotes: 4
Views: 7400
Reputation: 1328142
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
cwd
for 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
cwd
of VSCode,package.json
is echoed.
Clicking on the file name will result invscode/package.json
opening.The directory is changed to be the
template-string-converter
and thenpackage.json
is echoed.
Clicking on the file name will opentemplate-string-converter/package.json
.
Upvotes: -1
Reputation: 31
use
code -r <filename>
just remeber to install the code command to PATH
. in VScode, open the command palette and type "code", you should see a Shell Command: Install code to PATH option.
I really haven't actually seen any difference between using the command without the -r
flag.
Upvotes: 3
Reputation: 4885
Use code -r <file>
to open the file in the last active code window
Upvotes: 11