Cygwin terminal on VSC does not start from current directory - visual-studio-code

for some reason every time I open a new Cygwin terminaln on VSC, the working directory is set to /home/User by default. Buy I would want the working directory to be set, by default, to the path I am opening the Cygwin terminal from. I have installed the Cygwin terminal on VSC using Shell Launcher (Extension).

Related

How can I open toggleterm in my current working directory?

I have started to use neovim recently and installed toggleterm plugin for a terminal. When ever I am in a project and try to open the terminal it starts on my home directory rather than the current working directory of the project.
For example: Suppose I am currently on a project which is at ~/projects/new-project/news-app and when ever I start toggle term the terminal's location is at ~/.
What can I do to make it open on current project directory (~/projects/new-project/news-app).
Operating system: WSL2 Ubunutu22.04
Neovim version: 0.6.1
I have tried enabling autochdir = true in toggleTerm.lua file and also tried adding autocmd BufEnter * silent! lcd %:p:h to my init.vim config file but this does not solve my problem.

Set the path in portable vscode installation powershell terminal

I have multiple versions of vscode installed on my system with portable mode. I start each of them via a desktop shortcut. Since they are in portable mode, their installation directories are not in the default PATH variable.
When I make a new powershell terminal window, the portable vscode directory is not on the path. I need the command "code" in the terminal window to run the same vscode version that the terminal shell is running in. In other words, if I am running a portable vscode, and I open a powershell terminal and type the command "code", I want it to run the code.exe file that is the same as the vscode I am running it in, and not a different one, and not get the "object not found" message. For various reasons I do not want to have to type the full path.
So, in essence, I want to add a directory to the path variable when vscode starts up, with that directory being the base directory of the vscode itself.
You need to set this in: File/Preferences/Settings then select Workspace, there go to: Terminal/Integrated:Cmd and there specify An explicit start path where the terminal will be launched.

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 can't write to files in Bash for Windows

I've been using Bash for Windows recently (its the Ubuntu "app") and I can open VSCode from the bash command line but when I try to save any modifications I've made to the file, it just says permission denied.
I've tried creating the files directly from VS Code's terminal but in that case it doesn't print out an error message but it also doesn't save anything.
That happens because you dont have permissions to write in the system32 folder. If you run the Ubuntu application as an administrator, you'll get the permissions to write. However, you won't be really in that file, because of the way that the virtualization of files and errors might happear doing so, and I do not recommend to run the console in a privilege mode (for seccurity issues).
Fortunately, in version 1903 of Windows 10, this will change, and you'll be able to navigate the WSL folders via Windows Explorer, and for sure that issue will disappear.
Edit: the best practice, you do the work in a folder in the Windows File System, and cd to there in the WSL console. VSCode has this integrated very well, if you have an open file in VSCode you can just do New Terminal and choose a WSL terminal. The terminal will already be in the folder where you file is.

start ubuntu as terminal in project folder

I added the following line to my settings in VSCode:
"terminal.integrated.shell.windows": "C:\\Users\\bd\\AppData\\Local\\Microsoft\\WindowsApps\\ubuntu.exe"
When I now start a terminal ubuntu is started in my user's home folder. How is it possible to start ubuntu in the project folder?
The thing is wsl can start any linux that I set using wsl /setdefault I dont like to rely on such a setting but want to specify the one I want to start. I want it started in the project's folder.
Edit:
I change into some project directory and call wslconfig.exe /s Legacy. When I now invoke wsl Bash is started in the current folder.
I return to cmd and call wslconfig.exe /s Ubuntu. When I now call wsl Store Ubuntu is started in the current folder.
wsl.exe seems to start Ubuntu differently than ubuntu.exe does. ubuntu.exe always starts in the user's home dir.
I assume that what you want to run in the VSCode terminal is the Windows Subsystem for Linux (in particular the Ubuntu variant).
To do so, you should run wsl.exe, using this setting:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\wsl.exe",
This will start up a Windows Subsystem for Linux shell inside the terminal. If you have installed Ubuntu, that is what will be run.