-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows Terminal: Open terminal in current folder via single command #620
Comments
What happens if you use The alias should already launch a WindowsTerminal, but I'm not sure if it launches in the path that you specify |
@joandrsn This is great, I didn't know. Thanks. |
@joandrsn Thanks! It even launches in the current directory! |
How do you pass a directory path to wt.exe. Something like this:
|
Tried but Always opens in Default folder for both CMD and PowerShell. I can open the WSL Ubuntu shell in the current folder with |
Remove |
Hello @DHowett-MSFT, |
@DHowett-MSFT, this doesn't work in the latest version 0.5.2661.0 :( |
For me, it doesn't work either :( |
As of v0.5, that actually won't work any longer. You'll need to set |
I'd also like to open new tabs in the current directory |
@zadjii-msft , this doesn't work in v0.5.2681.0 |
Does not work with 0.5.2762.0 either.. |
To be clear, removing |
|
@DHowett-MSFT it seems to me that an approach of having settings in a config file ( |
If I recall the conversation from last month, it was: Clearing the “startingDirectory” setting by deleting it from your user profile (in the specific case of the two or three default shipped profiles), instead of setting it to #607 specifies that we will support command line arguments, one of which will be the starting directory override. This seems to be in line with my understanding of your understanding of this conversation. 😄 |
For me setting "startingDirectory": "." does the job. |
is there another issue for having the terminal default open to say |
@carlinmack I don't think that's entirely necessary.
|
It defaults to system32 in those case for me. |
Thanks @torpederos "startingDirectory": " Checked. Both works fine for me. My solution. @RickStrahl have written a good blog regarding this issue. Check it out. |
In my case this worked. "profiles":
{
"defaults":
{
"startingDirectory": "."
}, |
I don't know if you found -d and path |
works well in WSL2 |
You can set up the starting directory using your preferred address, either globally or for a specific profile. To have a context menu to open it in the current folder, create and save a .reg file with the content below. Ps.: change {USERNAME} to your username.
Double click the saved file to add these entries to the registry. |
Does anybody know why Also clicking the |
Nope, you should probably file a new issue so we can follow up with you and figure out what's going on
That's how it has always worked - in 1.7 there's
Pretty sure that's how it's always worked - it'll always use the |
I'm using the context menu to open wt in a specific folder (using the entry generated by wt). That will open the first tab in that folder, but new tab will open in system32. Before i used my own context menu entry: $exe = (Get-Command wt).Source
$ico = Resolve-Path "$PSScriptRoot\wt.ico"
$title = "Windows Terminal here"
New-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere $title
New-ItemProperty HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Name Icon -Value $ico -Force
New-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere\command -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere\command """$exe"" -d ""%L"""
New-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere $title
New-ItemProperty HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere -Name Icon -Value $ico -Force
New-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere\command -Force
Set-Item HKCU:\SOFTWARE\Classes\Directory\background\shell\WTOpenHere\command "$exe"
# Currently not supported until v0.9
#Remove-Item HKCU:\SOFTWARE\Classes\Directory\shell\WTOpenHere -Force -Recurse |
Yep, that's exactly how it works. You might be interested in #8933 |
@manishprivet Is this possible in windows? |
@kaaax0815 Yes this is for windows only |
@manishprivet But bashrc would be wsl not native windows. Or where should I put it |
@kaaax0815 In the WSL's bashrc file actually |
@manishprivet the matter has resolved itself. I changed the cmd search shortcut to wt and this fixed the path problem |
@KSneijders unfortunately we do not have that on wsl :( |
actually we do, but it does not work |
power shell also does not work |
I'm using Windows Terminal v1.11.2921.0
|
If anyone is looking for a solution without changing @ECHO off
wt -d .
exit /B !ERRORLEVEL! |
Thanks @DHowett-MSFT, I was making VSCode when pressing ctrl+ñ the external console For those who are interested, I used |
Current directory in Windows terminal using explorerYou can open current directory in Windows terminal using explorer using |
@jleaders the help text is understandably a little confusing in this particular case, because of the implicit It's just that CLI11 doesn't know how to wire the args for |
@nphmuller Referring to the first main discussion of thus topic, you can open a new terminal windows, placed in the current working folder, by typing "cmd" and press Enter in the url ##bar. |
solution |
[ Settings : "Startup" → "standard terminal application" ] change this to windows terminal -> All Terminals open now in the Windows Terminal. |
how to use |
The default behavior of
For those frustrated by this, here's a script you can put on your PATH (or in
wtd.bat: @echo off
if "%1"=="a" (
net session >nul 2>&1 || (
powershell -c "start -v runas '%~f0'"
exit
)
)
wt -d . |
When you have Terminal set as your default console host, you can also just go back to launching |
Yeah but all of those are more verbose than typing Besides, how would you launch Git Bash? Users should be able to invoke their default console host in the current directory when calling And it should never, ever default to opening in a system directory such as |
Currently I can open cmd and powershell in the current folder via typing
cmd
orpowershell
in the address bar of explorer (which opens via CTRL+D, so it's really neat and quick).It would be great if this was also possible with the new Windows Terminal. But since it's a Windows Store app I can't find an easy way to add it to PATH. It also doesn't respect the current folder when opening. It always starts in the default folder (
C:\WINDOWS\system32
for cmd and~
for Ubuntu).It would be great if this was possible:
It would also be nice if it could be opened with a short command.
The executable currently is called
WindowsTerminal
. Would be nice if we could simply type something liketerm
.The text was updated successfully, but these errors were encountered: