How do get my script file to console via Notepad++ external command?

前端 未结 1 1752
耶瑟儿~
耶瑟儿~ 2021-01-21 07:26

I am using Notepad++ for creating scripts and opening my active files from menu \"Run\" -> \"Open current dir cmd\". This works fine and the result is:

c:\\scrip         


        
相关标签:
1条回答
  • 2021-01-21 08:07

    The final code line would mean the CD and the script invocation being treated as one command. Separating then with && should help.

    cmd /K cd $(CURRENT_DIRECTORY) && $(FILE_NAME)
    

    However, that would do the CD then execute the command. I do not know of any way to enter a command but not execute it.

    A poor solution would use the command below. You could copy and paste the echoed command then add in any parameters needed. Setting "Quick edit" mode on the window would make the copy and paste quicker.

    cmd /K cd $(CURRENT_DIRECTORY) && ECHO $(FILE_NAME)
    

    I have adopted a different approach for my own scripts although they do not have parameters that I need to enter. Edit the file (but not with Notepad++ as it overwrites the file just before it exits):

    C:\Users\AdrianHHH\AppData\Roaming\Notepad++\shortcuts.xml
    

    I have added some lines to the <UserDefinedCommands> section:

    <NotepadPlus>
        ... unchanged
        <UserDefinedCommands>
            ... unchanged
            <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>
            <Command name="Run as command" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /C &quot;cd /d $(CURRENT_DIRECTORY) &amp;&amp; $(FULL_CURRENT_PATH)&quot;</Command>
            <Command name="Explorer with selection" Ctrl="no" Alt="no" Shift="no" Key="0">explorer $(CURRENT_WORD)</Command>
        </UserDefinedCommands>
        ... unchanged
    </NotepadPlus>
    
    0 讨论(0)
提交回复
热议问题