Jump to content

webkenny

Member
  • Posts

    4
  • Joined

  • Last visited

Everything posted by webkenny

  1. I think it's the only workflow for it that I know of. I hasten to say its the best because that would be biased. Heh. You can contribute to it here if need be - https://github.com/webkenny/alfred. It probably needs a refresh but I don't think Shortcat yet is scriptable. So this is kind of a workaround type deal. Edit: Sorry for stupidly long delay.
  2. Hi all! So I'm finally getting around to doing my very own workflow programming and I've run into some weirdness creating a Workflow that Runs a Bash Script in Alfred v2. I've tested this bash script on the command line and it works a treat. In fact, most of the workflow works in Alfred but a couple of things are funky: When using \n inside my echo commands it literally prints \n instead of using a new line. I'd like to format my virtual hosts files as I have them now. It's even more critical for /etc/hosts where that needs to on a new line. When running the mysql logic - It doesn't create the database. It will, however, start MySQL which is something. Note I have tried to both make the commands sequential and used the && distinction. Neither works. The long and short of this is that basically I am creating a new local site on my stack. I create a directory, a virtual host entry, an /etc/hosts entry, and a MySQL database. Simple enough. I am sure this is due to my being very new to Alfred workflows. Probably something silly. Any help you can offer would be appreciated greatly. Interpreter is /bin/bash - All of the escapes are checked in the workflow window (Backslashes, Brackets, etc.) and the whole script looks like this... site="{query}" # Create a new directory mkdir ~/Sites/$site # Create a new entry in the Apache virtual hosts file. echo "\n<VirtualHost *:80>" >> ~/Sites/httpd-vhosts.conf echo " ServerName $site.localhost" >> ~/Sites/httpd-vhosts.conf echo " DocumentRoot \"/Users/ksilanskas/Sites/$site\"" >> ~/Sites/httpd-vhosts.conf echo " ErrorLog \"/Users/ksilanskas/Sites/Logs/$site-errors.log\"" >> ~/Sites/httpd-vhosts.conf echo "</VirtualHost>" >> ~/Sites/httpd-vhosts.conf # Ensure MySQL is running and then create the database. mysql.server start >> /dev/null && echo "CREATE DATABASE $site" | mysql -u root -proot >> /dev/null # Add an entry to the /etc/hosts file and restart Apache osascript -e "do shell script \"sudo echo '127.0.0.1 $site.localhost' >> /etc/hosts && sudo apachectl restart >/dev/null\" with administrator privileges" Thanks again! P.S. To prove I did a little searching... I did find this but it didn't look like a complete topic... http://www.alfredforum.com/topic/879-create-mysql-database-from-script-action/?hl=mysql - I'd prefer to just stick with using command line on this one if possible.
  3. Simple workflow as part of a collection I'm starting. From the README: Shortcat Alfred Launcher 0.01 This simple workflow launches Shortcat (with the "ui" keyword) and runs it with the Alfred query. It's a simple bridge between Shortcat and Alfred. Since SC is not scriptable (Yet!) this is merely a keypress simulation. WARNING: This workflow assumes you are using {CMD-SHIFT-SPACE} (the default) as your Shortcat trigger. If not, you may have to modify the AppleScript included in the workflow for your needs. Grab it from the repository here: https://github.com/webkenny/alfred Enjoy!
  4. As a programmer, I often write emails, posts, white papers, and other such things with code embedded in a rich text document. I would love to share a workflow I am working on with the world but I'm having a hell of a time trying to get what should be simple to work. Here's the vision: Write some code in a document Select the text Fire a global hotkey which triggers an Alfred workflow Copy the text Use an AppleScript to format the text to a Monaco font, perhaps with a background color, etc. Paste the text back (which, in theory should replace what's selected) I am falling down miserably at this. Here's something I've tried but I'll admit my AppleScript-fu is a little novice. try try set old to the clipboard end try tell application "System Events" to keystroke "c" using command down delay 0.03 set input to Unicode text of (the clipboard as record) set txt to quoted form of ("<span style=\"font:14px 'Monaco'\">" & input & "</span>") do shell script "echo " & txt & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf" tell application "System Events" to keystroke "v" using command down delay 0.03 set the clipboard to old end try And just in case you need to see it, this is how I have this particular applescript configured in Alfred's workflow: Any help would be greatly appreciated. Thanks folks! Loving version 2 so far!
×
×
  • Create New...