Looking for help on setting up wsl in vscode terminal - visual-studio-code

If I'm in my terminal and open a file with the code command, vscode will launch and the terminal inside code will show my full zsh setup that I have configured in hyper terminal. But if I open up code through windows, and select wsl as my default shell, it's pretty much useless. Anything I try, like sudo, git, apt, etc will return a command not found message.
So if I want to commit any changes in the terminal inside code then I have to use the git bash shell. Is it possible to get my zsh working without first launching from my terminal emulator so I'm using wsl instead of git bash?

running wslconfig.exe /list in powershell showed me that WSL was set to docker as the default shell, so then running wslconfig.exe /setdefault "Ubuntu" in powershell fixed my problem.

Related

Visual Studio Code Opens and run scripts on the non-default terminal

Until yesterday, my VSC worked fine. I opened, edited, and run my python scripts without a problem.
However since today when I start my VSC session, it starts on Powershell Terminal, that doesn't recognize my conda enviroment despite I set the default terminal as cmd:
When I open the cmd terminal manually, automatically loads my conda env, however when I run the command "Run Python File in terminal" it always opens on Powershell
Any suggestion on how to fix this?

VSCode will not run default terminal upon startup

For months I have been using Git Bash as my default terminal. Upon start up it loads 1 terminal plus any additional terminals as defined in my "terminals.json" file using the "Terminals Manager" extension. Everything has been working fine up until today, when I opened vscode up and it launched powershell instead of Git Bash for all my terminals. I have restarted vscode, and also restarted my pc but that did not help.
As mentioned above it is my default profile:
And here are my settings:
Also btw I can still run bash on vscode and it works just fine, however it won't run on start up anymore.
Any idea what is happening?

nvm and gulp found on Visual Code terminal but not on linux terminal

I have Ubuntu LTS 20.04 running on wsl2 in Windows, this way I'm able to compile my JS/React code and run my php server in linux and use windows to code using Visual Studio Code.
This is running great, but a strange thing is happening, I installed nvm and gulp through the Visual Studio Code terminal and if I use them on the terminal it works fine but not if I do it outside the terminal (using Windows terminal), it says not found for both gulp and nvm.
I assume VSCode is adding a few things to the PATH but I don't know what to do for them to be found by the windows terminal (outisde VSCode terminal). Screen below. On the left is the result of running nvm list inside VS Code terminal and on the right on Ubuntu terminal, which can't find.
I'm a bit confused by your question. It sounds like you're installing programs on Windows through the VSCode terminal, and then trying to run them on Windows but it's not working. But then your screenshot shows the WSL Ubuntu prompt failing to find the command. Assuming you want to run these under WSL, log in to WSL Ubuntu and run this:
find / -name nvm
If you actually want to use the Windows terminal to run the program, you'll have to find where it is installed in Windows and make sure that's in your %PATH% but this doesn't seem like it's what you're trying to do.
The correct answer was provided by the comment from MindSwipe.
On VSCODE terminal if I "echo $PATH" it has the nvm directory in it while the $PATH on WSL doesn't, I assume VSCODE alters its own terminal PATH when the tools are installed using it instead of the global WSL path.
I've changed the WSL path and it's now working, how can I present the bounty to MindSwipe ?

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

Why working permanent alias in hyper terminal doesn't work in vs-code bash terminal?

I'm on Windows 10 machine and I just installed VS-Code to use instead of Atom. I tried to use permanent alias in VS-Code Bash Terminal which I had created & was working fine in Hyper Terminal, but it doesn't work in VS-Code terminal. Why is that & How can I fix it ?
I have
alias mongod="/c/Program\ files/MongoDB/Server/4.0/bin/mongod.exe"
alias mongo="/c/Program\ Files/MongoDB/Server/4.0/bin/mongo.exe"
in my '.bash_profile' file
In VS-Code terminal, try and check your alias is still defined:
alias mongod
cd ~
more .bash_profile
You will then see if said alias is still there in that VSCode environment.
If it is: do a source ~/.bash_profile, and the alias should be operational.
see also "Why ~/.bash_profile is not getting sourced when opening a terminal?"
~/.bash_profile is only sourced by bash when started in interactive login mode.
When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source ~/.bashrc.
So in your case, move those alias definitions to ~/.bashrc.