Administrators Leon Posted February 3, 2013 Administrators Share Posted February 3, 2013 Original post: http://web.onassar.com/blog/2012/06/30/osx-bash-script-execution-through-keyboard-shortcut/ While the full example is pretty thorough, I wanted to walk through the process I undertook to have some bash code/script run through a shortcut key. I'm going to split this into two pieces. Creating a ServiceFrom any application, you can go to the Application Menu, down to Services and choose one. These services can do a variety of things, such as copy/paste the open file's text, upload the file through an FTP application, etc. We want to create a service that runs a bash command/script. Prepare the bash command and test it in Terminal.app Open up Automator.app Create a new Service In the left column, under the Library header, choose the Utilities option In the column to the right, double-click the Run Shell Script option Paste your command into the textarea Above, under the Service received selected drop-down list, choose no input Hit Command-S to save it, and give it a name (in my case "rsync") Creating the shortcut keyNow that the service has been created, we want to make sure it is both accessible through the theServices submenu, as well as having a shortcut key bound to it. Here are the steps to do both: Open up System Preferences.app Go to the Keyboard settings On the left, choose the Services option Scroll to the bottom, and ensure the rsync (or whatever name you gave it) option is checked When selecting the service, a button titled add shortcut should become visible. Choose this, and add your shortcut 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now