• Login
Community
  • Login

Launching tail-f from the command line.

Scheduled Pinned Locked Moved General Discussion
14 Posts 3 Posters 2.6k 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.
  • D
    ddd ccc
    last edited by Apr 18, 2020, 1:40 AM

    Is it possible to launch the “Monitor (tail-f)” when opening notepad++ ? I’m trying to automate this when opening notepad++.

    1 Reply Last reply Reply Quote 0
    • E
      Ekopalypse
      last edited by Ekopalypse Apr 18, 2020, 11:59 AM Apr 18, 2020, 11:58 AM

      No, the possible commandline parameters do not include it.
      One could, depending on how complicated stuff goes, use one of the scripting plugins like PythonScript(PS) or NppExec to try to solve it.
      For example, PS has notepad.getCommandLine method if you would
      start npp with something like notepad++.exe -multiInst -? you can
      check for the question mark and call notepad.runMenuCommand('View', 'Monitoring (tail -f)') if needed.

      A 1 Reply Last reply Apr 18, 2020, 12:56 PM Reply Quote 3
      • A
        Alan Kilborn @Ekopalypse
        last edited by Apr 18, 2020, 12:56 PM

        To use a scripting plugin like Pythonscript like @Ekopalypse suggests, you’d have to put the code to do this in its “startup” script.

        I suppose you’d also have to have some mechanism to tell it which file you wanted to put in “tail” mode, as the typical remembered session contains more than one file, and you probably wouldn’t want to put ALL files in “tail” mode.

        E 1 Reply Last reply Apr 18, 2020, 1:14 PM Reply Quote 1
        • E
          Ekopalypse @Alan Kilborn
          last edited by Apr 18, 2020, 1:14 PM

          put the code to do this in its “startup” script.

          preferable a “user” startup.py and in addition one needs to
          change the PS configuration from LAZY to ATSTARTUP.

          A 1 Reply Last reply Apr 18, 2020, 1:19 PM Reply Quote 2
          • A
            Alan Kilborn @Ekopalypse
            last edited by Apr 18, 2020, 1:19 PM

            Probably @Ekopalypse will come up with a nice, short, fully working example for the OP. :-)

            1 Reply Last reply Reply Quote 1
            • E
              Ekopalypse
              last edited by Apr 18, 2020, 1:20 PM

              If OP wants to go that way - maybe. ;-D

              A 1 Reply Last reply Apr 18, 2020, 1:22 PM Reply Quote 0
              • A
                Alan Kilborn @Ekopalypse
                last edited by Apr 18, 2020, 1:22 PM

                @Ekopalypse

                It would serve as a good example of “adding a custom command line parameter to Notepad++” for future readers as well, who might have different need than “tail”.

                E 1 Reply Last reply Apr 18, 2020, 1:23 PM Reply Quote 0
                • E
                  Ekopalypse @Alan Kilborn
                  last edited by Apr 18, 2020, 1:23 PM

                  @Alan-Kilborn

                  the issue is, that you cannot set a custom parameter but the question mark seems to work.
                  But I haven’t really checked the commandline code to see if there is
                  a possible workaround.

                  A 1 Reply Last reply Apr 18, 2020, 1:32 PM Reply Quote 1
                  • A
                    Alan Kilborn @Ekopalypse
                    last edited by Apr 18, 2020, 1:32 PM

                    @Ekopalypse

                    you cannot set a custom parameter but the question mark seems to work.

                    Ah.

                    Presuming it worked more fully, more questions arise:

                    • I have a Explorer right-click “edit with N++” thing that I often use to pull into an existing N++ instance already running. If one queried the command line after that, would they see the original command line, or the one from the right-click?

                    • Does a multiple instance invoked from the first instance impact?

                    E 1 Reply Last reply Apr 18, 2020, 2:38 PM Reply Quote 0
                    • E
                      Ekopalypse @Alan Kilborn
                      last edited by Ekopalypse Apr 18, 2020, 2:38 PM Apr 18, 2020, 2:38 PM

                      @Alan-Kilborn

                      you query the current instance, so you should always get the
                      commandline parameters associated whit this instance,
                      regardless if multiInst is used or not.

                      A 1 Reply Last reply Apr 18, 2020, 3:06 PM Reply Quote 0
                      • A
                        Alan Kilborn @Ekopalypse
                        last edited by Apr 18, 2020, 3:06 PM

                        @Ekopalypse

                        But I mean, to follow the OP’s example, maybe I have N++ running then I next want to run tail on a file, so I use Explorer with my special “tail with Notepad++” rightclick. I guess there would be no good way to do the trapping with P.S., even if Notepad++ interface to get the command line was better than it is.

                        E 1 Reply Last reply Apr 18, 2020, 3:15 PM Reply Quote 2
                        • E
                          Ekopalypse @Alan Kilborn
                          last edited by Apr 18, 2020, 3:15 PM

                          @Alan-Kilborn

                          maybe I’m, again, not seeing the wood because of the trees.
                          Let me try to explain what I understand so far.

                          There is an running (or not as it doesn’t matter from my understanding) npp instance.
                          Now you click on the explorer context menu “open with npp in tail mode”.
                          This shortcut must be configured, of course, with something like npp -multiInst -?
                          If that new instance starts up it will execute startup.py
                          And here we would check against the -? flag and act accordingly.

                          Is that what you are talking about or do I have a plank at my head?

                          1 Reply Last reply Reply Quote 0
                          • E
                            Ekopalypse
                            last edited by Ekopalypse Apr 18, 2020, 3:28 PM Apr 18, 2020, 3:28 PM

                            I was wrong, there is a way to provide user parameters .

                            By this we could start npp with something like notepad++.exe -multiInst -nosession -z -tailmode

                            and would be able to get it up and running

                            46f2ec37-183d-4597-9787-66e2fe10c988-image.png

                            1 Reply Last reply Reply Quote 1
                            • E
                              Ekopalypse
                              last edited by Ekopalypse Apr 18, 2020, 3:37 PM Apr 18, 2020, 3:35 PM

                              This PS, saved as startup.py (user NOT machine and PS configuration changed from LAZY to ATSTARTUP) should do the trick

                              e6fb0b18-db39-4bab-a14c-ebdea5b99411-image.png

                              from Npp import notepad, MENUCOMMAND
                              if '-tailmode' in notepad.getCommandLine():
                                  notepad.menuCommand(MENUCOMMAND.VIEW_MONITORING)
                              

                              and npp like this notepad++.exe -multiInst -nosession "FULL_PATH_OF_THE_FILE" -z -tailmode

                              1 Reply Last reply Reply Quote 3
                              7 out of 14
                              • First post
                                7/14
                                Last post
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors