microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.06k stars 8.24k forks source link

Windows Terminal: Open terminal in current folder via single command #620

Closed nphmuller closed 5 years ago

nphmuller commented 5 years ago

Currently I can open cmd and powershell in the current folder via typing cmd or powershell 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 like term.

kaaax0815 commented 3 years ago

@kaaax0815 Yes this is for windows only

@manishprivet But bashrc would be wsl not native windows. Or where should I put it

manishprivet commented 3 years ago

@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

kaaax0815 commented 3 years ago

@manishprivet the matter has resolved itself. I changed the cmd search shortcut to wt and this fixed the path problem

KSneijders commented 3 years ago

You can now just go to settings -> profiles (Powershell / Command prompt). And check the checkbox: 'Use parent process directory'

image

rafapaulin commented 2 years ago

@KSneijders unfortunately we do not have that on wsl :(

rafapaulin commented 2 years ago

actually we do, but it does not work

rafapaulin commented 2 years ago

power shell also does not work

pratikbarve09 commented 2 years ago

So, none of the above answers worked for my use case. What I'd like to do is open a new tab using alt+shift+- and keep the previous folder. I tried using null, "." and "%__CD__%" as values for "startingDirectory" in different places of the JSON. I'm using version 1.4.2652.0 of Windows Terminal Preview.

One nice solution would be to have a new option like "keepCurrentDirectoryOnNewTab": true or something like that. Other way (that Kitty uses) is having a special value called current when specifying the directory.

I'm using Windows Terminal v1.11.2921.0 this worked for me:

  1. in windows terminal, under default profile, add startingDirectory value to "."
  2. if you are going with explorer, in the address bar type "wt" and it will open your default profile in that directory or right-click and choose "open windows terminal here" option to open the default profile (if you have edited the registry for this)
  3. for every profile add a value of "startingDirectory" to "."
krlvm commented 2 years ago

If anyone is looking for a solution without changing startingDirectory, I have placed such a file in %SystemRoot\System32 named wtx.cmd:

@ECHO off
wt -d .
exit /B !ERRORLEVEL!
AEROGU commented 2 years ago

Remove startingDirectory from your profiles.json.

Thanks @DHowett-MSFT, I was making VSCode when pressing ctrl+ñ the external console wt.exe appears, because the integrated one has problems with unicode in windows and, when I did it, it always started in my %USERPROFILE%, your solution worked, now runs in my project directory.

For those who are interested, I used wt --window 0 focus-tab so that if I already have a WindowsTerminal window open, it will be raised instead of creating another instance.

ErcinDedeoglu commented 2 years ago

You can now just go to settings -> profiles (Powershell / Command prompt). And check the checkbox: 'Use parent process directory'

image

thank you! this solution is the best solution. and still working

sanayvarghese commented 1 year ago

Current directory in Windows terminal using explorer

You can open current directory in Windows terminal using explorer using wt -d .

jleaders commented 1 year ago

Please add wt -d to wt -h image

zadjii-msft commented 1 year ago

@jleaders the help text is understandably a little confusing in this particular case, because of the implicit new-tab subcommand that's used when no subcommand is provided explicitly. You'll note, -d is under wt new-tab --help

image

It's just that CLI11 doesn't know how to wire the args for new-tab up to the help message for the root command's help text.

filiSpinelli commented 1 year ago

@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. image

loan-mgt commented 11 months ago

solution wt -d .

6philipp9 commented 7 months ago

[ Settings : "Startup" → "standard terminal application" ] change this to windows terminal -> All Terminals open now in the Windows Terminal.

candrapersada commented 1 day ago

how to use %USERPROFILE% in start menu if use Use parent process directory for Open terminal in current folder via wt