run system commands on save if certain criteria are met
-
I was wondering, is it possible to get Notepad++ to run some system commands if the current file’s folder meets some criteria?
I use clasp for developing Google Apps Script code. When you have a local copy of a Google Apps Script project the folder will have a
.clasp.json
file in it.I want it so if when I save a file and the folder has this
.clasp.json
file then it should automatically run a system command:cmd /c "cd $(CURRENT_DIRECTORY) && clasp push"
.Is this possible? I saw NppEventExec but could not figure out how to get it to do what I am after.
-
@imthenachoman said:
I was wondering, is it possible to get Notepad++ to run some system commands if the current file’s folder meets some criteria?
you should use lua or python script plugin for get notification when file is being saved
-
I don’t know Lua but I know Python. So I could create a Python script to run a function on save that would check for the existence of a specific file in the directory and then run other system commands?
-
Yes, using the
Pythonscript
plugin for Notepad++ :# -*- coding: utf-8 -*- from Npp import editor, notepad, NOTIFICATION def callback_npp_FILESAVED(args): for (filename, bufferID, index, view) in notepad.getFiles(): if bufferID == args['bufferID']: # do your stuff with "filename" file here break notepad.callback(callback_npp_FILESAVED, [NOTIFICATION.FILESAVED])
-
Humm. Thank you! I will give it a try.