Alternatively, you can use a single -e option, the write the text out fully between a pair of opening and closing quotes that includes linefeeds, etc: You can use the -e option as many times as you like, with each occurrence being one line of AppleScript code that combine to form a complete script. osascript: This is the shell program that executes AppleScripts (or JavaScripts) either by way of a script file that is provided as the argument (which isn’t done here, because I’m not using a script file), or by way of plain text specified line-by-line by each use of the -e option.So the scripting portion I did already, which looks like this: cd "$(osascript \īreaking it down (for the benefit of anyone else wishing to learn what’s happened here), there are two separate commands used here: Tell application "Terminal" to tell the front window ¬Īnother thought, given you spend a lot of time in Terminal, would be to define an alias or function in Terminal called ppath that would execute the first line of the AppleScript to obtain the insertion location then do a simple cd that would complete the process: cd "$(osascript \įor us bash-challenged folks, would you mind showing us exactly how to do that? Here’s the entire macro performed by a script in three lines (I’ve used the continuation character to spread it over a few lines for readability): tell application "Finder" to get the ¬ Then it struck me how you started with the bulk of the macro depending on an AppleScript, before switching to other actions to do what would seem to me to be quicker and simpler to do with the AppleScript, since it is there anyway. Where you’ve asked Finder to give you the location pointing to the front Finder window, or, if one doesn’t exist, then to default to the desktop, there’s a specific property that does exactly this called insertion location, which means you can replace the entire tell block at the start with a single line: tell application "Finder" to get the insertion location as alias
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |