Community
    • Login

    Open Command at Current Cursor...

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 6.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Gary FurashG
      Gary Furash
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by

        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

        1 Reply Last reply Reply Quote 1
        • Gary FurashG
          Gary Furash
          last edited by

          Thank you! Works like a charm. Is there a way to add other things to that menu?

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by guy038

            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

            1 Reply Last reply Reply Quote 0
            • Scott SumnerS
              Scott Sumner
              last edited by

              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 &quot;$(CURRENT_DIRECTORY)&quot; &amp;&amp; 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.

              1 Reply Last reply Reply Quote 2
              • Scott SumnerS
                Scott Sumner
                last edited by

                @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 “&quot;" and “&amp;”, respectively,
                
                1 Reply Last reply Reply Quote 1
                • Gary FurashG
                  Gary Furash
                  last edited by

                  Great suggestions. However, if I change %APPDATA%/Notepad++/Shortcuts.xml it instantly changes it back next time I run the file.

                  1 Reply Last reply Reply Quote 0
                  • Scott SumnerS
                    Scott Sumner
                    last edited by

                    You must edit shortcuts.xml with an editor other than Notepad++. That may be the problem.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors