Opening Bash on Windows on a specific folder - windows

I started using bash on the Windows anniversary update and recently I tried to start an Android project but want to open the terminal on the project folder. I tried googling this but couldn't find any solutions that allowed for this through command line.

I didn't find a way to set a default folder so I just created a script that would cd into the right folder and ran that every time I opened bash

Related

Why does running a .sh script from Visual Studio open the file instead of running it?

I am attempting to run an .sh script (which itself is supposed to kick off a series of unit tests in flask) from within Visual Studio Code running in Windows 10 and for some reason no matter what I try it only opens the file for editing instead of actually running the file.
This is the exact command I am typing:
C:\Users\my.user\MyRepo>.\scripts\run-unit-tests.sh
Here are my notes:
This is a brand new installation of Windows 10 where I believe I have enabled WSL2
I am completely unfamiliar with doing development from within Windows (coming from a Ubuntu/Linux background)
My goal is to run this script from within the built in terminal in VS Code, however I have also tried running it from a cmd prompt and also from powershell and both of those also result in opening the file in VS Code.
Addendum: more notes:
I actually have two windows machines. one is my personal machine, the other provided by my work. For whatever reason this file works fine on my personal machine but does not on my work machine. Also the bash script is in a repo which was created by others at my company so i'm certain that this can be made to run without modifying the .sh file itself.
I figured out what was going on.
In windows there are default file associations. Mine was set up to run Visual Studio Code for the .sh file extension. Also, windows does not know how to handle .sh files by default. There were likely many potential fixes for this however the one that worked was for me to re-associate the .sh file extension to open with Git Bash which I happened to also have installed on this machine.
Thanks all who tried to help.

How to open Anaconda Prompt from Windows Explorer URL?

I would like to open the Anaconda Prompt within a current folder using the URL in Windows Explorer similar to how you open a Git Bash terminal using "git-bash here".
I was unable to find a way to do this.
I tried to add the installation directory to the system PATH variable but that didn't work.
Any ideas if this is possible?

issue with Git Bash

I am able to open git bash by typing "git bash" in the windows explorer URL space on one of my other laptop.
However, I'm trying to do it on another laptop of mine and it refuses to work. A black terminal opens for a split second and then disappears.
I've reinstalled it multiple times to no avail.
Currently using v2.27 of Git on Windows 10.
Any idea how I can get this working again? It's super convenient for me.
In system variables the C:\Program Files\Git\cmd is added to Path.
To launch git-bash.exe (which is the program which will use git.exe internally)
directly from windows explorer address field, you need to make it findable in Path.
git-bash.exe is in C:\Program Files\Git\ (notice the lack of cmd directory)

Have WSL shell open to project directory in Windows Visual Studio Code

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?)

Using Automator to copy files, execute Cordova not working

I'm trying to create an Automator workflow which:
gets files and folders of a directory
copies those files and folders to another directory (with overwrite)
run a shell command: cordova prepare
The issue i have is, I'm working in one folder and wanting to be able to run an application that does the above, rather than manually do it every time i need to refresh the Cordova app.
The first two of the above works fine, i see the files copy/overwrite as they should, but when it gets to the shell command it returns the error code "cordova - command not found (127)"
Is it because I have Cordova installed for my user only and it wont execute as root (or whatever OS X the Automator user is)? If so how would i get it to run as another user or install it globally?
I've tested a simple command such as "cd ~/Sites/ && open ./" which works fine without error. It's just the cordova not found thing which i have going on at the moment.
Thanks in advance.
When you call the cordova command, are you using the entire path to the Cordova app? Something like this:
/Applications/Cordova.app

Resources