Hacker News new | ask | show | jobs
by vbezhenar 2205 days ago
Sorry for offtopic, but I'd like to share a tip I can't imagine living without. You can type cmd in explorer address bar and it'll open cmd in that directory (probably works with any other program in your %PATH%). Also you can type `explorer .` in cmd to open explorer in the current directory.
14 comments

Another tip: Shift-Right-Click a file in Explorer and "Copy as path" will appear in the context menu.

Puts the full file path in your clipboard.

Da fck.

I recently learned you can add this feature to the right click context menu via adding a registry entry.

If I’d’a known shift-right click I wouldn’t make bothered.

Shift right click has always been the way to get the "advanced" context menu. Well, at least back to Windows 95. Fun fact: since the shortcut for the context menu is Shift+F10, you'll always get the extended menu since you'll always have shift pressed when the menu appears.
I’m one of the ten thousand today:

https://xkcd.com/1053/

Did not know that! I've always used the "menu key" for keyboard access to the context menu instead.
Looks like shift+menu key does the same thing, too
I only learned last year (when I was still on Windows 7) that you can right-click drag (for example a file on to an email in outlook) and it will throw a pop-up where you can select "Create hyperlink here".

It dropped my jaw...after decades using Windows I had never known right click and drag was even a thing!

Control+drag = copy; Shift+drag = move; Control+Shift+drag = link.
Yes, but right-click drag means clear visual confirmation of the action, the physical movements are the same for all types of operation, and you can make up your mind what to do after you've indicated where. I only use shift or control if I accidentally left-click drag.
The Right-Click Drag context menu is also an Explorer Shell Extension Point (going way back) and some apps can add additional behaviors to it beyond Cut/Copy. 7-Zip for instance includes a lot of options in a sub-menu. For instance, Right-Click Drag a set of .zip files in a Downloads folder to a more permanent home folder and you can select 7-Zip > Extract to *\ and 7-Zip will expand all of the .zip files into folders based on the names of the .zip files.
From memory, this was added in Windows Vista. On XP and 2000, you needed the registry entry. Another popular similar entry was "Command Prompt here".
Oh yeah! Microsoft released PowerToys back in the day that had clever things like this.
The new PowerToys [1] are interesting too, though somewhat different in scope from the old ones.

[1] https://github.com/microsoft/PowerToys

equivalent on Mac: Alt + Right Click.
Windows requires the modifier key held down when clicking, but macOS adjusts the open menu according with currently held down modifiers.
True, and definitely something Windows should have.
If you're talking about Mac, you mean "Option", not "Alt".
OMG!!! where have you been my whole life. you just saved me tons of stress when getting a file path in explorer
Also in the Shift-Right-Click is open command prompt in directory. Nice symmetry there.
I've always used "start ." in cmd to open explorer. "start" is kind of useful to know since it triggers the default action for a file, e.g. "start foo.txt" opens it in Notepad or whatever your default text editor is.

"start "."" however opens another cmd window. Consistency is not a strong point.

start uses the first quoted argument as the window title and with your example the actual argument is missing, hence you get a new console window.
Aaargh. I always forget that while UNIX strips one layer of quotes from arguments, DOS and its inheritors have no parsing and just pass the whole thing through. So you can have semantically meaningful quotes.
Speaking of weird Windows/Unix quoting complexities, the following makes a WSL equivalent of cmd's start:

  alias start="cmd.exe /c start '' ${@//&/^&}"
I don't remember where I found the details, but they're not of my invention. This may have some strange edge case failures, but works pretty well in my experience, including with spaces in filenames, but only for Windows folders, not WSL-specific ones (cmd.exe barfs, but maybe it would be possible with PowerShell).
Windows Explorer has been so slow that I actively avoid using it and use the command prompt instead. Even on an SSD, opening a folder sometimes takes several seconds while Explorer scans that folder with a progress bar on the address bar (and does I-don’t-know-what in the background). I see this happening for downloads and many other folders.

I use Keypirinha, Everything, and other tools to get work done.

In many of those cases it's shell extensions installed by other apps that make Explorer slow. I forgot how you can check that, but you can.
This! Especially f'in dropbox.. swear to god everytime you try to click on a file it does some type of request to try to "help" you.

Which is fine, but it gets slow as hell. I have a brand new very fast machine and all the sudden explorer was getting so terrible. I downloaded something to disable the dropbox shell extensions and back to very nice performance.

Still it's sign of bad design IMO. Proper design would show menu immediately with some indication that some items are still loading, while running shell extension callbacks in background. But probably that's too fundamental to change at this moment. I remember entire Windows shell freezing because of similar things back in Windows XP. At least now different shell parts don't freeze all at once.
Yeah, and but there are SO many plugin systems designed decades after Explorer that do the same thing. Hindsight is 20/20.
“autoruns” from sysinternals
ShellExView from Nirsoft
You can also shift right click the background of an explorer window to open a terminal session (powershell or cmd depending on the release I think). If you need a administrator prompt you can do that from explorer's file menu in Windows 10.
Since ribbon UI you can always add ribbon items to the quick access toolbar (right click -> add to quick access) which can be accessed by the alt + (item slot number)

I always used to add powershell and powershell (admin) from the File menu to the quick access toolbar which allows me to quickly open the powershell in the current folder via keybind (Normal ps: alt + 3, Admin ps: alt + 4)

I wish they would add new windows terminal and all user defined profiles to the file menu.

You can also type "wt" and have Windows Terminal open your default shell (presuming Windows Terminal is installed). This makes it really convenient to access WSL wherever you need it.
Also if you aren't on hte mouse, CTRL+L in the folder jumps the cursor to the address bar.
Thank god they finally copied this behavior from web browsers. I had a machine trapped on a Windows 8 until recently and lack of ctrl+l was infuriating! If you are "one of the 10000" about this today, don't beat yourself up about this, explorer's ctrl+l hasn't been around very long.
I think it used to be F4 or F6 or something for Explorer. I also used to use F6 in firefox, took some time re-learning Ctrl+L when that changed. (Edit: F6 still works, but it cycles elements (one which is the address bar) so ctrl+l is better)
Alt-D. I have this shortcut so well ingrained in my head that duckduckgo is nearly broken for me. They have a single shortcut alt+d that searches for results from the same domain. This is enabled by default, so if you use ddg as your default, it can't be disabled for private browsing mode (I use private browsing mode to avoid opening a full browser session with extensions and saved tabs/windows).

Anyone who captures keyboard shortcuts in the browser using function keys like Ctrl/alt (outside of applications like games, rich text entry, and software like Google apps) needs to rethink the way their website works. This includes squarespace(?) intercepting ESC, and websites that do server-side searching. Worse yet, when I press Ctrl+f, I want to search the current page for a word, not search your website. (I saw this recently, and it was only made worse because you couldn't actually dismiss the search overlay without reloading the page)

This also works in all modern browsers, I use this hundreds of time per day.
As does ALT+D, as with browsers.
Since the Ribbon was added in Windows 8 opening a shell in your Windows default shell option (which defaults to PowerShell in recent Windows 10 now, but can be swapped back to CMD) has been directly on the File menu-tab. This also means there's a direct keyboard shortcut (Alt+F,R or Alt+F,S for more options in Windows 10, including Alt+F,S,A to open an Admin PowerShell).

The Ribbon gets a lot of flak for seeming complex or ugly (including from this article), but it added a lot of sweet Power User tools in easy to find places, and everything keyboard shortcut-able, if you give it a chance.

Equivalents on a Mac: drag a folder onto terminal's icon in the dock to open a shell there, and "open ." in a shell to open finder there.
`start .` would also open the current directory. if memory doesn't fail me (I'm now a kubuntu user), start is the equivalent of double-clicking, so `start somefile.txt` would mimic double-click on somefile.txt, `start .` would double-click on the current directory, and so on
How did you happen upon this tidbit?

I imagine going through an actual book and doing all the exercises, or something similar like a course for Windows or whatever might cover it?

Not the one you asked but i'll answer:

I discovered it myself: Most of the program like this one take a path to know where it should open.

I was searching how to open vscode is current folder ("code .") and figured you could do with a bunch of other tools, like cmd, gitextensions, powershell, explorer...

This is a great tip, thank you!

I spent an hour trying to get "Open Command window here" back on Windows 10, to no avail... and it was this simple :D

Another tip -

From the taskbar, you can middle-click on any preview window that pops up to close that window.

cat e.bat

  @echo %~f0
  @if %1. == . goto simple
  @rem explorer /e, %1
  explorer /e, %1
  @goto done
  :simple
  explorer /e,.
  :done
open Explorer from cmd prompt, either where you are or where you want it