How to log commands that are run through command palette in Sublime Text 3 - sublimetext

I know that commands can be logged by going to the console View -> Show Console and typing
sublime.log_commands(True)
However, the commands that are run through the command palette are not logged, it just shows:
command: show_overlay {"overlay": "command_palette"}
Is there a way to log the commands run through the palette?

There's not currently a way to log the commands that are being executed from the command palette, no. If I recall correctly, this was possible in older builds of Sublime, but around the time that the command palette gained the ability to accept input for commands like View Package File, it stopped working. That might be an offshoot of the mechanism that's used to trigger input handling in the command palette, but that's just a guess.
Normally a plugin could be used to track something like this because EventListener classes have events to tell you before and after commands execute. However, there's an open issue on the tracker regarding the command palette on triggering on_post_window_command which is likely caused by the same thing as the commands not showing up in the log.
Currently the only way to know what command and arguments are being invoked from the command palette is to introspect the sublime-commands file that's providing them.
Unlike menus, commands in the command palette are not allowed to have dynamic captions, so it's a relatively simple matter to find the command entry that has a "caption" for the text you know you're picking.
The tricky part can be in determining where the command is coming from. In the console, sublime.find_resources('*.sublime-commands') will show you a list of every known command file, and you can open them via View Package File in the command palette.
Generally, anything that ships with Sublime is in Default/Default.sublime-commands, and anything that's added by a package is prefixed by the name of the package that added it, which can aid in determining what file to check.
Note that there are some commands in the command palette that are added by Sublime and don't come from a command file; commands that insert snippets and commands that change the syntax. Those are determined on the fly since the list of syntaxes and snippets is subject to change.

Related

Alternative to cmd and powershell for stdout output only

My use case:
I kick-off a Python script from a button within Excel to do some data aggregation. The setup currently works nicely, but I would like:
Cmd to never accidentally pause - it's a known feature of the command prompt to pause on any text selection: Avoid pausing tasks when select something on PowerShell and Command Prompt
To let the cmd prompt look more like a pop-up
I have noticed NSIS installers outputs it's commands in a little logging box:
Question:
I would like to know if there are any programs out there that does most of what I want already. E.g. something like RunLikePopup.exe c:\path\to\script.bat, with output like:
Not sure what you are really after. I 'll give it a try.
In case you build an application as 'console'-only than that results in a 'command-line-interface [CLI]' Look-and-feel. Plane and simple. The output of a NSIS script (.nsi file) can not be paused as it is simply the output of the compiler executing the script code. 'Pausing' that would instantly mean pausing the compiler to do its work. I see no reason why you would want that.
Example Unix 'more' command (sending text oriented content to stdout. CLI...)
https://en.wikipedia.org/wiki/More_(command)
In case you need to 'catch' the output from the NSIS compiler here is what you need to do:
run NSIS from (Windows) CLI:
makensis [ option | script.nsi | - ] [...] > compiler_log.txt
What you appear to want is typically named 'output redirect'. (https://ss64.com/nt/syntax-redirection.html). In case you need to 'catch' the outpout from a NSIS script at compile time, please use NSIS ' CLI and redirect the (compilers) output to any text file (e.g. compiler_output.txt)
PS. In order to ensure receiving good quality answers, try to be as specific as you can in your questions.
I have written a Freeware editor ME "Martins Editor" where you can send text via inpipe:
[C:\]dir /s | me in
"in" always shows the first page (does not scroll), "ins" scrolls and "inp" scrolls page by page. In this context, "me in" is a substitute for "more".
Then you will see the output in the editor. ME is a simple editor with the focus on multiplatform text (different EOL encodings, codepages). It has additional Wordstar ("IDE classic") key setting and HTML/XML highlightning. It is available for Windows, OS/2, Linux and MacOS.
http://www.hypermake.com/english/betatest.html#hd117
The 2016 version is still current. In the next weeks, I publish a new version.
I am working on a cmd.exe window replacement (commandline frontend) "MeShell" based on ME with look-and-feel of a normal commandline window. Because on the lack of a modern comfortable commandline window on the old OS/2 platform which is still alive (http://www.arcanoae.com), I will publish an OS/2 version first. If this version works fine, I will publish a Windows version later. In the context of MeShell, I improve the inpipe functionality of ME which is still buggy and does not support colors in the 2016 version.

Read current terminal

Is it possible to read what's currently displayed on the windows terminal pragmatically using any available API?
For example, I've got an app that tail's some log files. I'd like to be able to hit a key and open a text editor at the line that is currently being viewed. The problem is the terminal also has scroll bars.
Not easy. Perhaps you could capture the screen and use OCR to identify its contents, or make a shortcut to some sort of macro that selects all the screen and copies the text. But there is no API available to perform the task you ask.
Of course, you can tee the command you're running in the console to a file, and open such file with an editor whenever you like, however it will show the full output of the command and not the visible part. If you like more information on that topic, it is answered in SO - Displaying Windows command prompt output and redirecting it to a file
.

How to get colourful integrated terminal ("cmd") in VS Code

Recently after updating my VS Code I saw the following image in the Release Notes (in the Split terminal feature section)
I can't figure out a way to add such Syntax Highlighting in my terminal. Obviously, this is bash in the integrated terminal. Well, I'm using Command prompt and I don't seem to find any satisfying answer for getting colored text on my terminal (that does not mean just foreground or background color). Mine looks like...
Is there a way to fill this dull terminal with interesting text colors.
The upper one is the output of something called "node"
the second one is your terminal
so the first one is an outputstream of e.g. an program which formats stuff a bit else, also is output of an program in a terminal displayed differently than just the shell
and now to your question, the shell inside vscode has the same theme like your standard shell
so windows -> cmd, ubuntu bash, ...

How to run Octave from a Notepad++ file line by line or by sections?

I am looking for a way to have my Notepad++ window open for editing my code and run it line by line or by sections (more than 1 line) while I am editing. It would be like having a real IDE; the output could be shown in the same window (Notepad++) or directly in the Octave window.
I have tried what many many sites say. That is, writing this:
C:\Software\Octave-3.6.4\bin\Octave\Octave-3.6.5.exe "$(FULL_CURRENT_PATH)"
in the Run window in Notepad++, saving and giving it a shortcut. However, it is still not working. When I tried to run it, the black window starts showing-up but then it disappears and nothing else happens. In my Notepad++ window I have only one line (for now) where I have tried just "b=4" or "3*4". I have done this with and without semicolon at the end. Nothing happens.
I have Windows 8.0, Notepad 6.5.5 and Octave-3.6.4. I already change the octaverc file in Octave to make it work with Notepad++. I have work already only in the command line in Octave and is working fine. The Octave I installed was exactly "octave-3.6.4-vs2010-setup", it says it was compiled for Visual Studio 10. Is that the reason why this is not working?
Any help will be appreciated...
regarding Octave not processing the command: use supposed command line outside the N++ and see if it works. If not, find a way to make it working, then transfer it back to N++ (and use the token "$(FULL_CURRENT_PATH)" instead of concrete filename)
regarding running the code in smaller portions: if you app can accept the code directly in the command line (SQL command line tools I use can do this), then you can use token "$(CURRENT_WORD)" what stands for content of current selection (all tokens are in wiki)

Keep focus in command window when debugging MATLAB

Often in MATLAB I turn on 'automatic' debugging with dbstop if error. When an error occurs, the function enters debug mode, and I am able to query the variables in the command window and see exactly what is going on. Very useful.
However, when this occurs, the focus switches to the editor. To me this seems counter-intuitive; we are in debug mode, so I want to find out what is going on, not look at the code (which I can already see in the adjacent window). I always immediately tab back to the command window.
So my first question is: Is there any point in accessing the editor at this point? What can I usefully do, when my script has crashed, in the editor?
And secondly: If I want to, can I change MATLAB's default behaviour to keep the focus in the command window?
To your second question:
If you use MATLAB's desktop environment, just deselect "Open Files when Debugging" in the "Debug" menu.
If you use MATLAB without the graphical desktop you can change this preference by modifying your matlab.prf file. This file stores preferences set from the GUI. The menu option described above makes the same changes as the manual process described below.
NOTE: Editing this file is entirely unsupported. Do so at your own risk.
Open the file from the MATLAB command prompt,
>> edit([prefdir '/matlab.prf'])
Or use the prefdir command in MATLAB to find the directory and then open the file in whatever editor you prefer.
Search for a line that says
EditorGraphicalDebugging=Btrue
Change it to read
EditorGraphicalDebugging=Bfalse
If the line doesn't exist, add it to the file.
Restart MATLAB.
You can use the invocation stack to see how you came about to the particular error position. Sure, you can use dbup and dbdown for this in the command window, but it's much easier in the editor.
Also, seeing the variables (and their values, using mouse hover) in the context of the code that caused the crash is far better for understanding the root cause of the error than just seeing the static values.
I can answer only your first question.
Things you can do in the editor:
Mouse hover a variable, which pops up a 'quick view' window.
Any action you can do when not in debug mode, treating the function as a script - running a line (highlight + F9), running a code block, etc.

Resources