Open Eugeny opened 4 years ago
How do you do this in fish?
The latest nightly now includes experimental implementation that reads CWD from the shell process' memory. Currently only works with cmd/clink.
Maybe this can help? https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory
In this tutorial, you learn how to configure your shell to allow Windows Terminal to open tabs in the same path.
I was able to get Powershell works but not for MINGW/Git Bash (in Windows Terminal and Tabby).
The Shell working directory reporting opens in ~/AppData/Local/Programs/Tabby
@mariovalney thanks! But CWD detection already works for both CMD and Powershell. I need to come up with a similar snippet for Cygwin and MSYS2...
Current state:
Done a bit of more exact testing (for later reference):
Shell | Accepts WD | Reports CWD |
---|---|---|
PowerShell | ✅ | ✅ |
Git-bash | ✅ | ✅ |
cmd.exe (stock) | ✅ | ✅ |
cmd.exe (clink) | ❌ | ✅ |
MSYS2 | ✅ | ❌ |
WSL | ✅ | ❌ |
Cygwin | ❌ | ❌ |
The Shell working directory reporting opens in
~/AppData/Local/Programs/Tabby
Hey @Eugeny & @mariovalney! I was hitting the same issue, and found an alternative that's working for me. Instead of $(pwd)
as described in Shell working directory reporting, I'm using:
${PWD/#\/c/C:}
This issue appeared to be occurring for me because in Git Bash pwd
would yield a path like /c/Users/something
. Presumably a path of this form is being passed to the shell process of the new tab which isn't a valid Windows path and therefore results in the fallback to ~/AppData/Local/Programs/Tabby
.
The above snippet just replaces the starting /c
with C:
, so this simple snippet wouldn't work for other drives!
With that change I was able to open new Git Bash, Powershell & CMD tabs in the correct working directory detected from a source Git Bash tab - hope this helps!
CWD detection on Windows is far from perfect - I currently rely on either parsing the CWD from the prompt (which is not 100% reliable), or the shell being configured to report CWD via an escape sequence.
This leads to new tabs sometimes not reusing the current tab's CWD and CWD not being restored on terminal restart.