I have to "source ~/.zshrc" everytime I open a new terminal only in vscode - visual-studio-code

Currently have to manually write source ./zshrc to get my zsh plugins to work within the vscode terminal window, however I dont have this issue if I open a zsh shell outside of vscode. I am using Debian on wsl2.
In terminal I get proper syntax example (due to a plugin)
However in vscode I dont unless i run source ./zshrc
As seen here:

Related

VS_Code : Shell Integration Failed To Activate

When i hover on my vscode terminal name: (in terminal's upper right corner named "Powershell")
it shows : shell intergartion failed to activate,
how to solve this error, while
I tried installing vs code again but still no change, and also installed powershell 7
There are a few potential solutions for this issue.
Make sure that you have the latest version of VS Code and the Shell Integrate extension installed.
Check that the integrated terminal in VS Code is set to the shell you want to use (e.g. PowerShell, Command Prompt, Bash).
Try running VS Code as an administrator.
If you are using Windows, try adding the path of the shell you want to use (e.g. C:\Windows\System32\bash.exe) to the "terminal.integrated.shell.windows" setting in your VS Code settings.
You can also try reinstalling vscode and the extension.
If none of the above solutions work, you can try searching for specific error messages in the output panel of vscode or in the output of the terminal.

Is there a way to open a file in VS Code from the integrated terminal/codespace?

The integrated terminal in VS code means that you can run builds, scripts and other commands and see the results as is. Sometimes though they produce output files that you'd like to view in an editor, like a logfile or exception trace.
Is there a way of running a built-in command in the terminal to say 'please open this file in vscode', specifically in a codespace? On macOS, you might use 'open' or 'start' on Windows, but this only works if your codespace is hosted on the same machine that you're browsing to.
It would be great if there was a command that could be run that would open up the corresponding file in vscode, such that you could set the VIEW or EDITOR environment variables and have such operations edit in the file itself. Then (for example) running git in the integrated terminal would open a new vscode editor for writing the git message, instead of the default vi/emacs/notepad/edit.com/pico/nano.
Yes you can. Use the command:
code filename
Or, if you are running an early release (or GitHub codespaces):
code-insiders filename

Open file from integrated terminal in VS Code

I have VS Code setup with WSL on my Windows 10 machine. I am trying to find the command I can use to open an existing file from the integrated terminal in the current VS Code window.
I tried code filename, which launches a new VS Code window. I tried with code -r filename, but it also launches a new window.
Is there a way to quickly open a file when I'm focussed on the terminal?
As of version 1.43.1, this appears to now work as expected, without additional add ons.

Visual Studio Code - Where is the terminal history saved?

I noticed that the command history is saved when using Visual Studio Code. Using the arrow up and down keys, I can toggle through previously issued commands in the integrated terminal.
Where is the terminal history saved on the drive? Is it possible to open a file in notepad (or notepad++) and investigate the complete history, delete it?
I'm using Windows 10, and I have concluded that deleting the folders C:\Users\john\.vscode and C:\Users\john\AppData\Roaming\Code will not delete the terminal history for a particular project.
VSCode terminal use external shell. For linux the default shell is bash, I am not so sure about window, but I guess the default shell for window is powershell.
If your terminal shell is indeed powershell, this should help you locate the log file.
On Linux & MacOS, type the following command to display the path of the history file:
echo $HISTFILE
The history file may be different between VSCode and your regular terminal.
So you should type this command within the integrated terminal.
On Ubuntu you can see your history using this command:
vi ~/.bash_history

How to open a file from the integrated terminal in Visual Studio Code?

Is there a way of opening a file from the terminal in Visual Studio Code that opens in the same vscode instance that runs the terminal? Similar to c9 tool in Cloud9.
I'm aware of the code tool, but when you run code something.php from the integrated terminal it opens a new vscode instance, which is not what I want...
You can use -r or --reuse-window command line option.
code -r something.php
just
code file_name
I tried it on Win10 and on Linux (Ubuntu)
I don't know what operating system you're using, but on MacOS you can just say open filename.ext in the integrated terminal, and it will open a new tab in the same VSCode instance, ready for you to edit.
If you are having command not found: code in macOS, use a full path to it.
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code -r [filename]
Open Visual Studio Code
Press CMD + SHIFT + P (this opens "Command Palette")
Type shell command
Select “Install code command in path”
Navigate to any project from the terminal, and type code .
If it didn't work, select “Uninstall code command from path” first, then reinstall it again.
I use code -r . to open the current directory in the main window.
You can use the code command from the CLI to open a file, but if you want it to open in the existing window, either use code -r <file> as mentioned in other answers (which does work for me on Ubuntu Linux), or, if -r does not work (under WSL?), make sure window.openFilesInNewWindow is either off or default in settings.json or the in VS Code settings UI, then use code <file>.
Many things can be found in open --help
A work around that worked for me on MacOS is:
open -a 'Visual Studio Code.app' something.php
in the version 1.31.0 that I have installed, on Windows 7, the only way I found to do this is to e.g. change the file associations in system so that .cproj and .cs files are opened by Visual Studio Code by default, and type "filename.cs" in Terminal to open file by that name in the same window... -r option is not working for the first call (opens a new window), but with each subsequent call that same window is correctly reused. ok can't get to open whole directories this way - it's a bit shoddy anyway. probably it would be more convenient to use an outside shell and work with "-r" option
VSCode 1.64 (Jan. 2022) comes with a new command:
Keyboard Navigable Links
Previously, link navigation in the terminal required the use of a mouse.
Now, links can be opened using only the keyboard via the following commands:
Terminal: Open Detected Link... to view all links (web, file, word)
Terminal: Open Last Web Link... ex: https://github.com/microsoft/vscode
Terminal: Open Last File Link... ex: /Users/user/repo/file.txt
Check if the last command Terminal: Open Last File Link... would help in your case.
See also "Terminal shell integration"