Sublime Forum

let sublimetext run last used build command

#1

As an example, there are two files, main.py and module.py, I could only run the project when main.py is in the current active tab window by Ctrl + B. However, a big amount of my code work is in module.py, after some modification of module.py, I have to switch to main.py to run and test my code, frequently switching to main.py is not convenient, I wonder if there is a way to run module.py when the current file in the active tab window is module.py rather than main.py.

Briefly, I have main.py and module.py opened in Sublime, after running main.py I switch to module.py, how to run main.py when the current file in the active tab window is module.py rather than main.py?

I found a solution in this post , but that requires to configure manually, I expect there is a feature to remember last build command so that I can repeat last command by some shortcut. It would be welcome if someone can guide me to write some plugin to implement the feature.

0 Likes

#2

Sublime Text remembers the last build system being executed. But as default python build system always passes the file name of the currently active view to python interpreter, the way to go is that from the linked post. You’ll need a custom sublime-build file which always executes main.py.

1 Like

#3

To speed up the back and forth progress, I told him to use project-specific build system and (from my observation) the “automatic build” always executes previous selected build in another Chinese forum but since he’s here, he probably doesn’t like this solution.

I guess what he wants is a plugin that always executes the exact same shell command with the last selected build executed after command variables are interpreted.

0 Likes

#4

@jfcherng Glad to see you here, thanks very much for your kind help !
@deathaxe

I am not inclined to write sublime-project files manually per project, I expect there is a feature to remember last build command so that I can repeat running the command by some shortcut.
After running my Python script, I saw the running command was logged in the console of sublimetext

, I just need to get the latest running command and then run it by my plugin if triggered, but I cannot find a way to get the command , any help ?

0 Likes