AppleScript

AppleScript for Duplicating Tabs in Terminal

When I work on Rails, I would like to have two tabs open that are in the same directory. One for server log and another for running commands (e.g., script/generate) After opening the TextMate project file. I type ⌃⇧O to open the main directory in Terminal.

Then I run the following AppleScript.

tell application "System Events"
    -- Need to wait a bit to avoild some conflict
    -- No key should be pressed when this script is being run
    do shell script "sleep 0.75"
    tell application "Terminal" to activate
    -- Change Kotoeri Input to Alphanumeric mode
    keystroke ";" using {control down, shift down}
    set the clipboard to ""
    keystroke "pwd | pbcopy"
    keystroke return
    keystroke "t" using command down
    keystroke "cd "
    keystroke "v" using command down
end tell

I put the script in ~/Library/Scripts/Application/Terminal, and assigned ⌘⇧D using FastScripts.

TUAW AppleScript Learning

Cory Bohon at TUAW is writing a series of tutorials on AppleScript.

Check out the first two articles.

A Simple AppleScript to Change the Encoding with CotEditor

I have tons of sample codes written in Shift-JIS with line endings of CR/LF (Windows). Below is an AppleScript to convert such documents to UTF-* encoding with LF (Unix). I use CotEditor because its encoding detection works better (for me) than BBEdit.

tell application "CotEditor"
    activate
    set properties of document 1 to {line ending:LF}
    convert document 1 to "Unicode (UTF-8)" with lossy
    -- Use regular expressions to replace yen symbol with backslash
    replace document 1 for "\x{00a5}" to "\\" with RE and all
end tell

Subversion AppleScripts for Finder

A collection of AppleScripts to operate subversion via Finder. This is open source. You can see the code written.

If you want to assign shortcuts, go and get FastScripts. But, I think we can do something simliar with Quicksilver.

NetNewsWire to Yojimbo: Integration

Brought to you by earnmydegree.com: Want to learn more about coding and web design? Get an online web design degree and you can learn more of what you love! There are so many online univerisites that there’s sure to be a learning program that’s right for you. Find a great bachelor degree program!

Brian Yamabe on Yojimbo-Talk Discusson List shows two scripts to send NetNewsWire itmes to Yojimbo for bookmark items or archived items with tags.

The two scripts below are not my own making. Worked without a hitch for me.

NetNewsWire to Bookmark in Yojimbo script:

tell application "NetNewsWire"
    try
        set userInput to text returned of (display dialog "Enter Tag:" default answer "")
        set oldDelims to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {", ", ","}
        set h_tags to text items of userInput
        set AppleScript's text item delimiters to oldDelims
        if (index of selected tab is not 0) then
            set tabnum to index of selected tab + 1
            set taburls to URLs of tabs
            set h_URL to (get item tabnum of taburls)
            set tabtitles to titles of tabs
            set newItemTitle to (get item tabnum of tabtitles)
            tell application "Yojimbo"
                set newItem to make new bookmark item with properties {name:newItemTitle, location:h_URL}
                add tags h_tags to newItem
            end tell
        else if exists selectedHeadline then
            set h_URL to URL of selectedHeadline
            set h_title to title of selectedHeadline
            tell application "Yojimbo"
                set newItem to make new bookmark item with properties {name:h_title, location:h_URL}
                add tags h_tags to newItem
            end tell
        else
            error "No headline is selected."
        end if
    on error error_message number error_number
        if the error_number is not -128 then
            try
                display alert "NetNewsWire" message error_message as warning
            on error number error_number
                if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
            end try
        end if
    end try
end tell

NetNewsWire to Archive in Yojimbo script:

tell application "NetNewsWire"
    try
        set userInput to text returned of (display dialog "Enter Tag:" default answer "")
        set oldDelims to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {", ", ","}
        set h_tags to text items of userInput
        set AppleScript's text item delimiters to oldDelims
        if (index of selected tab is not 0) then
            set tabnum to index of selected tab + 1
            set taburls to URLs of tabs
            set h_URL to (get item tabnum of taburls)
            set tabtitles to titles of tabs
            set newItemTitle to (get item tabnum of tabtitles)
            tell application "Yojimbo"
                set newItem to make new web archive item with contents h_URL
                add tags h_tags to newItem
            end tell
        else if exists selectedHeadline then
            set h_URL to URL of selectedHeadline
            tell application "Yojimbo"
                set newItem to make new web archive item with contents h_URL
                add tags h_tags to newItem
            end tell
        else
            error "No headline is selected."
        end if
    on error error_message number error_number
        if the error_number is not -128 then
            try
                display alert "NetNewsWire" message error_message as warning
            on error number error_number
                if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
            end try
        end if
    end try
end tell

Put the scripts in Script Folder in NetNewWire.

NetNewsWire to Yojimbo

For app-specific hot keys, use FastScripts. Assign whatever keys you want.

NetNewsWire to Yojimbo with FastScripts
Syndicate content