5

How do I translate a directory in Bash on Ubuntu on Windows 10 so that I can invoke a Windows application via Bash and call that working directory as an option?

For Example:

From Bash on Ubuntu on Windows 10, I can get the path to my WindowsC:\ drive through /mnt/c/, which is useful for opening Windows-based GUI applications from the Bash command line; for instance, I can open Sublime Text with:

/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe

but I'm not sure how to use a command line option that will instruct the Windows application to use something in my current working directory. like:

pwd
/home/mark/example
ls
test.txt
mwalle@DESKTOP-LO101K6:~/lyn_solns$ /mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe test.txt
Unable to translate current working directory. Using C:\WINDOWS\system32

and Sublime Text opens up displaying a new blank file named test.txt in the C:\WINDOWS\system32 folder. I expected it to open the existing test.txt in ~\example.

muru
  • 197,895
  • 55
  • 485
  • 740
Mark
  • 71
  • 1
  • 6

1 Answers1

2

I eventually found an answer here: Where is the Ubuntu file system root directory in Windows NT subsystem and vice versa?. The command to access my Ubuntu user's test.txt inside the windows application sublime from the Ubuntu subsystem Bash:

/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe C:\\Users\\Mark\\Ap
pData\\Local\\lxss\\home\\mwalle\\test.txt
Mark
  • 71
  • 1
  • 6
  • Did you ever find a better workaround? Seems annoying to have to specify the full path to the file, test.txt everytime? – Vincent Jul 01 '17 at 19:55
  • 3
    The Linux home directory is located at the Linux side of WSL filesystem. Accessing files at the Linux side by Windows applications is NOT recommended, at least in present state of WSL. Please see the WSL blog for details. So, what the OP wants is better not to do at all. The WSL filesystem location is hidden for a reason. – ddbug Jul 04 '17 at 22:29
  • To elaborate on Mark's solution, I just set an env variable in my .bashrc to make it less annoying: HOME_WIN='C:\\Users\\{windows user}\\AppData\\Local\\lxss\\home\\{unix username}' – Dylan Hendricks Jul 04 '17 at 20:02