Open Command at Current Cursor...
-
I’d like to create a command to open a shell in a separate, normal window, at the current directory of the currently opened file. How do I do this? I tried Run (menu) but I’m not sure how to pass parameters or set it up. I tried NPPExec but even with START or CMD \c it either fails or opens it up in the little console window.
-
Hello Gary,
Maybe I’m completely wrong but, are you looking for the following N++ command, below ?
File - Open Containing Folder - cmd
Best Regards,
guy038
-
Thank you! Works like a charm. Is there a way to add other things to that menu?
-
Hi Gary,
Before the Notepad++ v6.5.2, starting with these two commands Open Containing Folder - Explorer and Open Containing Folder - cmd, in the File menu, they were stored in the shortcuts.xml file, in the UserDefinedCommands section, as below :
<Command name="Open containing folder" Ctrl="no" Alt="no" Shift="no" Key="0">explorer $(CURRENT_DIRECTORY)</Command> <Command name="Open current dir cmd" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /K cd /d $(CURRENT_DIRECTORY)</Command>
I, personally, modified these two commands a little bit :
-
I modified their names
-
I added shortcuts for the two commands ( ALT + SHIFT + E and ALT + SHIFT + C )
-
In the CMD command, I added the
/T:
option, to change the foreground and background colour of the CMD window<Command name=“Launch EXPLORER in current folder” Ctrl=“no” Alt=“yes” Shift=“yes” Key=“69”>explorer $(CURRENT_DIRECTORY)</Command>
<Command name=“Launch CMD in current folder” Ctrl=“no” Alt=“yes” Shift=“yes” Key=“67”>cmd /T:70 /K cd /d $(CURRENT_DIRECTORY)</Command>
So I presume, that you could customize your CMD command :-) Just execute the command
cmd /?
to get all the CMD options !Cheers,
guy038
-
-
Here’s a nice modification to guy038’s CMD window command, that will put the directory at time of launch into the title bar of the CMD window. This is handy when you have multiple CMD windows open, for quicker identification of which is which. Here it is:
<Command name="Launch CMD in current folder" Ctrl="no" Alt="yes" Shift="yes" Key="67">cmd /T:70 /K title "$(CURRENT_DIRECTORY)" && cd /d $(CURRENT_DIRECTORY)</Command>
The way it works is that the CMD.exe program is given TWO commands instead of one. The first command is the “title” command, which does the obvious thing and sets the text of the title bar of the CMD window. This must be separated from the second command (i.e., “cd”) by two ampersand characters (the way to tell the CMD.exe program to execute more than one command).
One thing I found interesting with testing this out is that when I was editing shortcuts.xml (with a non-N++ editor!), I used actual double-quote (“) and ampersand (&) characters in my edits. N++ changed them to “”” and “&”, respectively, when it next saved shortcuts.xml. That’s the data I’ve pasted here.
-
@Scott-Sumner said:
N++ changed them to “”" and “&”, respectively,
Sorry I didn’t check the preview well enough on this; it should have been more like:
N++ changed them to “"" and “&”, respectively,
-
Great suggestions. However, if I change %APPDATA%/Notepad++/Shortcuts.xml it instantly changes it back next time I run the file.
-
You must edit shortcuts.xml with an editor other than Notepad++. That may be the problem.