Skip to content

Instantly share code, notes, and snippets.

@Trevor-
Created September 21, 2018 05:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Trevor-/f661c2daf339f8f4a6afe65e0877bdb5 to your computer and use it in GitHub Desktop.
Save Trevor-/f661c2daf339f8f4a6afe65e0877bdb5 to your computer and use it in GitHub Desktop.
This will run a remote script on PhotoShop on the Mac
// See https://forums.adobe.com/message/10632458#10632458
if (app.name !== 'Adobe Photoshop') {
alert('Crash,for Adobe Photoshop only!');
}
var remoteCode = 'https://gist.githubusercontent.com/Trevor-/6a02d8cb49bbfeb9822f061dea300bc1/raw';
// this function is nicked from // https: //forums.adobe.com/thread/2364797
function getSystemCommandStdout(command) {
var stdout = "";
var tempFile = new File(Folder.temp + "/temp.txt");
app.system(command + " > " + tempFile.fsName);
if (tempFile.open("r")) {
stdout = tempFile.read();
tempFile.close();
tempFile.remove();
}
return stdout;
}
var result = getSystemCommandStdout("curl 'remoteCode'".replace("remoteCode", remoteCode));
// Set script args dosn't work on PS so just using setenv
$.setenv("envVar1", "Hello");
// Set environmental vars
$.setenv("envVar2", "World");
// Run the "remote" script
eval(result);
// Share functions and vars
blah(testVar, 'bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment