bash.exe
The Windows executable that runs Bash on Windows implicitly makes the current directory its startup directory.
This means that you can simply change the shortcut file that opens Bash and change its field Start in:
to open Bash in the directory of your choice (specify the usual path to Windows; it automatically goes to the /mnt/c
-prefixed path when Bash starts).
- Caution: the official
Bash on Ubuntu on Windows
shortcut (in the "Start" menu) transfers ~
as a launch directory as part of the field Target:
; just remove ~
from the value C:\Windows\System32\bash.exe ~
in Target:
and then fill in the field Start in:
.
Of course, you can create new shortcuts, each with its own launch directory, if necessary.
Adding a command Bash Console Here
to the context menu of folders in File Explorer
*.reg
( ) , .
Bash Console Here
, .
Bash.
: aux. cmd.exe
bash.exe
, cmd.exe
cmd.exe
.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\BashConsoleHere]
@="Bash Console Here"
"Icon"=hex(2):25,00,4c,00,4f,00,43,00,41,00,4c,00,41,00,50,00,50,00,44,00,41,\
00,54,00,41,00,25,00,5c,00,6c,00,78,00,73,00,73,00,5c,00,62,00,61,00,73,00,\
68,00,2e,00,69,00,63,00,6f,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\BashConsoleHere\command]
@="cmd /c cd \"%V\" && bash.exe"
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\BashConsoleHere]
@="Bash Console Here"
"Icon"=hex(2):25,00,4c,00,4f,00,43,00,41,00,4c,00,41,00,50,00,50,00,44,00,41,\
00,54,00,41,00,25,00,5c,00,6c,00,78,00,73,00,73,00,5c,00,62,00,61,00,73,00,\
68,00,2e,00,69,00,63,00,6f,00,00,00
[HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\shell\BashConsoleHere\command]
@="cmd /c cd \"%1\" && bash.exe"
PowerShell :
$null = 0..1 | % {
$key = New-Item -Force ('HKCU:\Software\Classes\Directory{0}\shell\BashConsoleHere' -f ('', '\Background')[$_])
$key | New-ItemProperty -Name '(Default)' -Value 'Bash Console Here' -Type String
$key | New-ItemProperty -Name 'Icon' -Value '%LOCALAPPDATA%\lxss\bash.ico' -Type ExpandString
$key = New-Item -Force "$($key.PsPath)\command"
$key | New-ItemProperty -Name '(Default)' -Value "cmd /c cd `"$(('%1', '%V')[$_])`" && bash.exe" -Type String
}
:
0..1 | % {
Remove-Item -Recurse -LiteralPath ('HKCU:\Software\Classes\Directory{0}\shell\BashConsoleHere' -f ('', '\Background')[$_])
}