Mac で現在アクティブなウィンドウのディレクトリ全体をコピーすることはできますか?
たとえば、Sublime Text で example.txt を開いているとします。そのファイルのフル パスを取得する Apple Script を実行できますか? (ファインダーに行かずに)。
その結果、/Users/Bob/Dropbox/example.txt がクリップボードに保存されます。
Mac で現在アクティブなウィンドウのディレクトリ全体をコピーすることはできますか?
たとえば、Sublime Text で example.txt を開いているとします。そのファイルのフル パスを取得する Apple Script を実行できますか? (ファインダーに行かずに)。
その結果、/Users/Bob/Dropbox/example.txt がクリップボードに保存されます。
次のようなスクリプトにショートカットを割り当てることができます。
try
tell application (path to frontmost application as text)
set the clipboard to (path of document 1) as text
end tell
on error
try
tell application "System Events" to tell (process 1 where frontmost is true)
value of attribute "AXDocument" of window 1
end tell
do shell script "ruby -rcgi -e 'print CGI.unescape ARGV[0][16..-1]' " & quoted form of result
set the clipboard to result
end try
end try
最初の方法は Preview、TextMate 2、Sublime Text、iChm では機能せず、2 番目の方法は Acorn では機能しませんでした。