4 ms·
For Windows users I have a closely related shameless plug: cdhere navigates your cmd.exe to wherever the current topmost Explorer window is pointed at. It's n
by skrebbel 13y ago
For Windows users I have a closely related shameless plug:
cdhere navigates your cmd.exe to wherever the current topmost Explorer window is pointed at.
It's not the same as the OP's trick, of course, but since you're voluntarily using Windows, I'm going to assume you "live" on the command line less than the average UNIX user, and more on GUI tools such as good old Explorer.
https://github.com/eteeselink/cdhere https://github.com/eteeselink/cdhere
- ams6110 13y agoYou could install cygwin and use the OP technique, though.
- tripzilch 13y agounfortunately cygwin takes a lot longer to start than cmd, so I use it only occasionally. are there any fixes for that maybe? :)
- keyboardP 13y agoYou can hold shift and right-click in Explorer and select "Open Command Window Here" (at least in Win 7 and 8).
- Too 13y agoOr even faster: shift + context menu button, then W.
- deleted 13y ago[deleted]
- CrazedGeek 13y agoAbout the same speed on Windows 8: File -> Open Command Prompt.
- skrebbel 13y agoYep, this works fine, until you did it a 7th time and end up with a task bar full of unused console windows.
- keyboardP 13y agoIf you want to reuse an existing cmd window you can type in "cd " then drag/drop the directory from any Explorer shell. You could also close the shell after finishing with it. Not trying to take anything away from your script, it has a use-case, but just pointing out that there are alternate solutions for systems that don't have your script installed.
- networked 13y agoI like this. On Windows you can also get a nice "browse for folder" dialog in batch files with Wfolder [1]. If you replace "cdwhere.exe" in your script (cdhere.cmd) with "wfolder.exe" [2] and put wfolder.exe in the same directory as cdhere.cmd then instead of going to the location open in the topmost Explorer window the "cdhere" command will ask you where to cd, starting at your current location (like so: http://i.imgur.com/3MCzD4b.png http://i.imgur.com/3MCzD4b.png). Edit: Wfolder comes with a script that's analogous to cdhere.cmd. [1] http://www.horstmuc.de/wcon.htm http://www.horstmuc.de/wcon.htm [2] I did it in http://pastebin.com/aq0FiKmz http://pastebin.com/aq0FiKmz.
- mistercow 13y agoI used to have a really hacky AppleScript to do the same thing in OS X. The crappy part was that launching the whole AppleScript runtime was really slow, but that was the only API I could find with getting that information from the Finder.
- mrmaddog 13y agoYou can also drag any file or folder onto your terminal, which will paste the absolute filepath at your cursor point.
- mistercow 13y agoYeah, but I rarely use the mouse when using either a file browser or the terminal, so switching to it is less convenient than a short terminal command.
- gizmo686 13y agoI'm not sure voluntary is necessarily true. I have had to use Windows several times because we were working with Windows only programs. On a different note, back in UNIX land I found myself doing the opposite of what you described: opening the file explorer to the same directory as the command-line. Of course, there is not much to that trick other than choosing an explorer that opens to the working directory or a path provided as an arguement.
- rntrg 13y agoAnother useful windows trick: to open a new file explorer window at the pwd of the command prompt, type 'explorer .'.
- recursive 13y agoor slightly shorter: 'start .'
- Livven 13y agoWhat many people don't seem to know is that the location bar in Explorer (at least on Windows 8) can act as a run dialog, and it supplies the launched program with the current folder as a parameter. So simply hit Ctrl+L and type "cmd" or "powershell" or whatever command from your PATH and hit enter.
- WalterGR 13y agoAmazing tip! FYI: On Windows 7, you need to press Alt+D to get to the location bar. (I believe that's the case for XP as well.) Ctrl+L doesn't seem to do anything.
- TeMPOraL 13y agoThanks for the tip! Neither Ctrl+L nor Alt+D work for me (Win7 Ultimate, 64bit), but even with clicking manually this is extremely useful for me.
- tripzilch 13y agoI have been using F6 in my browsers, and it does seem to focus the address bar in File Explorer too. You need to press Enter first to be able to type commands though.