Launching tail-f from the command line.
ddd ccc last edited by
Is it possible to launch the “Monitor (tail-f)” when opening notepad++ ? I’m trying to automate this when opening notepad++.
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.
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.
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.
Probably @Ekopalypse will come up with a nice, short, fully working example for the OP. :-)
If OP wants to go that way - maybe. ;-D
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”.
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.
you cannot set a custom parameter but the question mark seems to work.
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?
you query the current instance, so you should always get the
commandline parameters associated whit this instance,
regardless if multiInst is used or not.
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.
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?
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
This PS, saved as startup.py (user NOT machine and PS configuration changed from LAZY to ATSTARTUP) should do the trick
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