- Posts tagged ancelyn
- Explore ancelyn on posterous
Ancelyn: Geek's text expansion/ generation toolkit
Visit http://www.harshadsharma.com/e/ancelyn for updates
Problem: I hate to repeat myself, which is also one of the the reasons why I have a blog ;-) Anyway, so I have to type in similar stuff all the time… name, address, email, signature, ssh/gpg public key, licenses for software/images, copyright notices, short snippets of html for posting on forums, canned email replies that are personalized… and the list goes on.
I searched for a solution, found many that came close enough, but not quite fit my needs (you know this drill) so I created my own ;) I've named the software Ancelyn, that mean's 'Knight's spear attendant', a feminine form of 'Lancelot'… and Ancelyn, the software you are about to see does exactly that: Lets you choose your weapon from your collection of texts and scripts. Here's how i did it and you can too… First let me explain how this works, I have a folder that holds a bunch of txt and py files… these are plain text and python files, respectively.Have a look at a txt file:
And a very simple python file:
So my script installs as a "Service" in MacOSX, and can be summoned with a keystroke from just about any native Mac program… and then it shows this:
Suppose you type in 'thanks' and hit enter, the text from the file 'thanks.txt' will be inserted at cursor. In case you type in 'hello World' … 'Hello World' will be inserted at cursor.
First preference is to text files, if not found, it tries to run a python file by the name of first word… here: 'hello' and passes the whole text as 'arguments' to the script. Here is the automator service script:In Snow Leopard: Start Automator, select 'Service' and then figure out rest of stuff… it is right in front of you (above)
Make sure you set the right directory in the script above.Once you've saved it, the service will show up in System Preferences
Assign a keyboard shortcut by double clicking on right side of the name and you're done!
Now for something more complex… a script that generates basic html tags from information I supply…So 'html img foo.com/bar.png' will be converted to '<img src="foo.com/bar.png" />'And 'html a example.com' will be converted to 'example.com'
Use your imagination :-) Also, use the attached files if you like…
Dedication: Hey Ankita, this one's for you!
License:
# Copyright (C) 2011 by Harshad Sharma#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#










