I recently switched to using Visual Studio Code from Sublime Text and have a question about the terminal functionality. It looks like "Integrated Terminal" that appears at the bottom is mounted to the local file system out of the box.
What I'm wondering is if I can replace this local terminal with a remote server? I have the hostname, port, and login credentials and would love to be able to navigation the file system on our remote server (like using MobaXterm, PuTTy, etc) and then open code files in Visual Studio Code instead of vim or emacs. Is this possible?
Thanks!!
UPDATE: I have figured out how to rig this into VS code.
You can download git bash online and it will be mounted to your local machine. In VS Code, you can then Ctrl+Shift+P and type "Open User Settings". In the right pane, add this setting:
This will replace the default integrated terminal in VSCode with the git bash CLI client that was just installed in the location in the screenshot above. Now that you have your local file system mounted in VScode, you can execute:
ssh username#hostname -p <port>
Related
I am trying out the Remote - Containers VSCode extension. I get a docker warning and a prompt message if I want to continue but I can't type anything into the terminal. The cursor looks like it's active but nothing happens when I type.
So far I have tried:
Using iTerm.app instead of Terminal.app (in VSCode settings)
Disabled oh-my-zsh terminal plugin
Quit and start Visual Studio code
I solved this by using generating ssh key in the devcontainer and adding it to github.
I want to open a WSL directory in VS Code. What's the difference between the following two methods and which should I use?
First method, open WSL window. It's common.
Second method, directly open directory and select the directory in wsl$ path.
Visual Studio Code recognize better the Connection than opening it directly
In most cases, you'll want to use the "New WSL Window" (or its equivalent). This utilizes the "Remote - WSL" extension to connect to your WSL instance through a small server that it installs in your WSL user's home directory. You'll probably find it already installed in your case in ~/.vscode-server.
This server handles the "translation" between the Windows VSCode and the Linux files, folders, and processes.
An easy way to think about the difference between the two methods of opening a folder:
Using "New WSL Window" puts VSCode in "WSL/Linux" mode
Using "Open Folder" and opening \\wsl$\... directly keeps VSCode in "Windows mode".
Comparing the two techniques with a real file. I have a simple Python file in my WSL home directory that I wrote up for another answer a few days ago. If I:
Open my home directory through \\wsl$\ in VSCode, then the VSCode Python extension complains:
Python is not installed. Please download and install Python before using the extension.
Since I don't have the Windows version of Python installed, and VSCode is operating in "Windows mode", it can't find the Linux/WSL Python interpreter.
However, if I:
Open my home directory through "Remote-WSL: New WSL Window", then open my Python file, then VSCode finds my Python interpreter, and I can run and debug the file in WSL through VSCode.
Side note #1: There is another method that has the same effect as using the command palette's "New WSL Window" -- From inside a WSL directory, run code .
Side note #2: There may be times when you want to open a file that lives inside WSL in "Windows mode". You may want to run it in a Windows version of a tool (Python, Java, whatever) to check compatibility.
As a general rule of thumb, however, you should probably do your Linux development with files inside WSL using VSCode's "WSL Mode" and Windows development with files that live on a Windows drive using "Windows (a.k.a. normal) mode".
I have a windows subsystem for Linux Installed on my computer and am using it as the integrated terminal on Visual Studio Code. Every time I open a terminal however, it opens in the root directory rather than the current project directory like other terminals do.
Does anyone know of a fix for this?
I have tried messing with the Cwd of the integrated terminal settings but haven't had any luck.
Try using wsl.exe as the command for shell.
"terminal.integrated.shell.windows": "wsl.exe"
I know that is very late for this answer, but for me it just worked.
I put exactly as above and it launched in my home directory (that is /mnt/d/Users/Adrian).
I have the user setup of VSC, 1.30.1 and launch it from the Desktop shortcut.
After I configured terminal as wsl I go as below:
If I open a cmd windows I can launch it with code . it will launch in Windows home directory.
If move to some other folder (e.g Documents) and launch it with code . the bash will launch to that folder.
Otherwise I can launch it with code D:\Users\Adrian\Documents\VSC and the bash terminal will launch in \mnt\D\Users\Adrian\Documents\VSC
Tested the change both via menu File->Preferences->Settings and with Ctrl+Shift+P (Command Pallete), Terminal: Default Shell.
Tried with bash and wsl.
Maybe you have some other bash installed in the path? (e.g. git bash or MinGW bash?)
I have a python file in my Bash on Windows environment.
Is it possible to debug it with Visual Code or Visual Studio?
Can a debugger be attached to the Linux python version that exists in the Bash on Windows environment?
I think you've got a few options for this. If you're attempting to debug a python file that's saved on your home directory in Bash on Windows, you can navigate to your home directory in Windows by going to "C:\Users\[windows username]\AppData\Local\lxss\home\[ubuntu username]\". Then you can open any of your projects or files saved on your home folder in Ubuntu. You can even make a shortcut on your desktop or something to make it easier to access this folder.
However, if you need the environment that you have on Bash for dependencies or python modules, your other option is to install a GUI and Linux-compatible IDE of your preference on Ubuntu, and use Xming on Windows to run the IDE on your screen. A tutorial on how to do this can be found here.
If you need to debug a linux python program from Visual Studio, a simple Google search yielded this. I haven't tried it but this seems to be the solution you are looking for. For connecting over the network to Bash on Windows from Windows, use localhost for the host.
Your best bet might be to just move the file. Your normal windows system is mounted under /mnt/c.
You can just copy it to your desktop by doing
cp (path to your file) /mnt/c/(your username)/Desktop
When you need to access or edit it from bash, just cd to that location (or wherever else you choose to store it).
Interesting other idea: you could mount cloud storage (e.g. google drive) via fuse in linux then set it up in windows. Copy the python to it and you can edit in windows and access in linux as needed. (Google is your friend here; look into google-drive-ocamlfuse or gdrivefs).
Hope this helps!
jBit
I would suggest making use of the Remote - WSL extension for Visual Studio code. It allows you to easily access your Windows Subsystem for Linux (WSL) and use it as a full-time dev environment.
Here is an article on how to set up Visual Studio Code Remote-WSL.
After that is set up, you can quickly load your python file in the VS Code editor using a command like: code path/to/python_file.py
I created Android Project in Android Studio, now that I would like to push it into my repository.
When I enter the following command in Android Studio terminal:
git remote add origin https://..........
The following error is returned:
git is not recognized as an internal or external command, operable program or batch file.`
How can I fix this?
If "git" is not installed then you need to install git and while installation select option 'Use Git from the Windows Command Prompt'.
If "git" is installed but still you are getting "git is not recognized as an internal or external command" error then you need to set PATH variable to point to git executable. To do that follow the steps below:
Open My Computer, right click and select Properties
On this window, click on Advanced System Settings link which will open System Properties popup.
In that popup (under Advanced tab), click on Environment Variables which will open Environment Variables popup.
In that popup, select Path and click on Edit, which will open Edit Environment Variable popup
From that popup window, click on Browse and browse to the git installation directory. Mostly it would be "C:\Program Files (x86)\Git\bin", select the directory and click Ok on all opened popups.
You will need to close command prompt and open again. Git command should work now!
Most probably Git is not installed on your machine (or installed incorrectly). Open this link to download an installer. It should do the job for you.
There are also other ways to install Git on Windows.
When you install Git, you must select the option 'run Git from the Windows command prompt'?
Download the latest version of the Git from here : http://git-scm.com/download and try again!