![]() ![]() It’s a single action that executes the following script and puts its output on the clipboard: python:ĥ: ioCmd = 'tell application "Terminal" to get history of selected tab of window 1'Ħ: inout = applescript.asrun(ioCmd).split('\n$ ')ħ: print '\n'.join(inout.split('\n')) Although appscript still works with Terminal, it can’t be trusted to continue to work, so I decided to remove that dependency when I brought the script over to Keyboard Maestro. I wrote a Python script that did just that, using Hamish Sanderson’s now-deprecated appscript module. One solution, which I wrote about a few years ago, is to use the Terminal’s AppleScript dictionary to put the output of the last command onto the clipboard. Both of these are easily accomplished if I remember to pipe the output to pbcopy, but I often forget to do that until after the command is run. Or I want to take the output and paste it into a document. I often find myself wanting to use the output of a previous command as the argument to my next command. ![]() ![]() This history, however, applies only to the commands themselves, not to their output. That’s what I did with a couple of scripts that manipulate shell output in the Terminal.Īs you probably know, the bash shell keeps track of your command history, which allows you to rerun commands with just a keystroke or two. In some cases, though, I took the opportunity to rewrite scripts I wasn’t especially happy with and to simplify them by taking advantage of Keyboard Maestro’s built-in features. This has meant converting scripts into KM macros, which usually involves nothing more than pasting the script into an Execute Shell Script or Execute AppleScript action. I’m not unhappy with FastScripts-quite the contrary-but it’s silly to run both it and Keyboard Maestro, and I’m finally comfortable enough with KM to use it exclusively. Next post Previous post Some Keyboard Maestro Terminal macrosĪ couple of weeks ago, after nearly a decade of heavy use, I quit FastScripts and removed it from the list of Login Items on both of my computers. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |