diff options
| author | Glenn Smith <glenn@vector35.com> | 2021-06-18 15:46:01 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2021-08-03 17:36:33 -0400 |
| commit | 7d0b3327b26a655756951fa988f918f5cb6f728b (patch) | |
| tree | 6e300b354bd059cf83b4303f42e28eeb1f1bb6a9 /python/scriptingprovider.py | |
| parent | 9d711397052b185a03a233a557cad3a0947a4139 (diff) | |
startup.py file runs commands on startup
Diffstat (limited to 'python/scriptingprovider.py')
| -rw-r--r-- | python/scriptingprovider.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index 473cd36f..1bec8d61 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -609,6 +609,20 @@ class PythonScriptingInstance(ScriptingInstance): self.completer = bncompleter.Completer(namespace = self.locals) self.interpreter.push("from binaryninja import *") + + startup_file = os.path.join(binaryninja.user_directory(), "startup.py") + if os.path.isfile(startup_file): + with open(startup_file, 'r') as f: + for line in f.readlines(): + self.interpreter.push(line) + # Finish input in case the file does not end with a newline + self.interpreter.push('\n') + + else: + with open(startup_file, 'w') as f: + f.write("# Commands in this file will be run in the interactive python console on startup\n") + f.write("from binaryninja import *\n") + f.write("\n") def execute(self, code): self.code = code |
