Created
January 9, 2011 17:26
-
-
Save kyab/771834 to your computer and use it in GitHub Desktop.
(XCode4非対応)XCodeで現在開いているソースファイルのフォルダからターミナルを開始します。「ユーザスクリプトの編集」でディレクトリを「選択部分」にしておいてください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
#カレントディレクトリを取得 | |
dir = `pwd` #エディタにフォーカスがないと、上手くそのファイルのディレクトリに移動できない・・。 | |
puts dir | |
#ターミナル.appにさせる処理(AppleScript)を文字列に詰める | |
terminal = "\\\"Terminal\\\"" #\"Terminal\" | |
cmd1 = "\\\"cd /\\\"" | |
cmd2 = "\\\"echo foo\\\"" | |
cmd3 = "\\\"cd #{dir}\\\"" | |
script = <<SEND | |
tell application #{terminal} | |
activate | |
-- do script with command #{cmd1} | |
-- do script with command #{cmd2} | |
do script with command #{cmd3} | |
end tell | |
SEND | |
p script | |
`osascript -e "#{script}"` | |
#ターミナルの扱いについては、OpenTerminalHereのスクリプトを参照した。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment