Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Brandon Payne http://paynito.livejournal.com

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

quicksilver tags in geektool script version 3

// can anyone tell me what this is? Is it applescript?
How do I call it from geektool? I found this here
http://theappleblog.com/community/development/588-displaying-quicksiler-tags/#post6596

set QuicksilverTags to (path to home folder as string) & "Library:Caches:Quicksilver:Indexes:QSPresetQSFileTagsPlugIn.qsindex"

do shell script "grep string " & (quoted form of POSIX path of QuicksilverTags) & " | awk {'print $1'}"

set theTags to result

--> From the MacScripter.net Text Delimiters Tutorial.
set newText to switchText of theTags from "qs.tag.file" to ""
to switchText of currentText from SearchString to ReplaceString
        set storedDelimiters to AppleScript's text item delimiters
        set AppleScript's text item delimiters to SearchString
        set currentText to currentText's text items
        set AppleScript's text item delimiters to ReplaceString
        set currentText to currentText as Unicode text
        set AppleScript's text item delimiters to storedDelimiters
        
        currentText
        
        set this_text to currentText
        
        set new_text to ""
        
        --> From the MacScripter Forum.
        repeat with myPara in paragraphs of this_text
                if new_text does not contain myPara then set new_text to new_text & myPara & return
        end repeat
        set new_text to (characters 1 thru -2 of new_text) as text
        
        set more_text to new_text
        set replace_text to ""
        
        --> From MacScripter Forum.
        repeat with myPara in paragraphs of more_text
                
                if replace_text does not contain myPara then set replace_text to replace_text & (text 9 thru -10 of myPara) & return
        end repeat
        
        set output to "Tags: " & return & replace_text
        
end switchText -- the end of the handler.

quicksilver tags in geektool

// this code taken from http://bbs.applescript.net/viewtopic.php?id=20330

do shell script "grep string /Users/username/Desktop/QSPresetQSFileTagsPlugIn.qsindex | awk {'print $1'}"

set theTags to result

set newText to switchText of theTags from "qs.tag.file" to ""

to switchText of currentText from SearchString to ReplaceString -- the handler
   
   set storedDelimiters to AppleScript's text item delimiters
   -- this simply stores the current value of AppleScript's AppleScript's text item delimiters
   -- so they can be restored later (thus helping to avoid potential problems elsewhere).
   -- Remember, we always set them back to what they were.
   
   set AppleScript's text item delimiters to SearchString
   -- AppleScript's AppleScript's text item delimiters are now set to "Purple"
   
   set currentText to currentText's text items -- note we have changed currentText's value
   -- create a list of text items from the original text, separated at the points where the
   -- current text item delimiter ("Purple") appeared.
   --> {"What, ", " Shoes?"} - Note that the spaces and punctuation are retained.
   
   set AppleScript's text item delimiters to ReplaceString
   -- AppleScript's AppleScript's text item delimiters are now set to "Green"
   
   set currentText to currentText as Unicode text
   -- coerce the list {"What, ", " Shoes?"} to Unicode text. This operation will also
   -- insert the current value of AppleScript's AppleScript's text item delimiters ("Green")
   -- between each of the listed items
   
   --> "What, Green Shoes?"
   
   set AppleScript's text item delimiters to storedDelimiters
   -- restore the value of AppleScript's AppleScript's text item delimiters
   -- to whatever they were on entering the subroutine. Remember that a call to this
   -- might have been made from within a section of script that had the TIDs set to
   -- something else. Hand the result back with the TIDs as they were.
   
   currentText
   -- return the now modified text (and restored TIDs) -- "What, Green Shoes?"
   
   
   set this_text to currentText
   
   set new_text to ""
   
   --Loop through paragraphs of old text
   repeat with myPara in paragraphs of this_text
       --Check for paragraph’s contents in new text
       --If not there add new text to end of new text
       if new_text does not contain myPara then set new_text to new_text & myPara & return
   end repeat
   --Remove final return
   set new_text to (characters 1 thru -2 of new_text) as text
   
end switchText -- the end of the handler.

Display Quicksilver (Finder Spotlight Info) Tags in Geektool

// stick this into the terminal it generates a text file that you can display with geektool
grep string /Users/username/Library/Caches/Quicksilver/Indexes/QSPresetQSFileTagsPlugIn.qsindex | awk {'print $1'}  > /Users/username/Desktop/tags.txt
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed