수색…


소개

Applescript는 터미널 명령 줄에서 직접 사용하여 다양한 작업을 수행 할 수있는 강력한 스크립팅 언어입니다.

이 절에 나열된 모든 예제는 터미널 응용 프로그램에서 사용하기위한 것입니다.

Safari 또는 Google 크롬에서 현재 URL 가져 오기

터미널 명령 줄에서

Safari 에서 현재 URL 가져 오기

osascript -e 'tell app "safari" to get the url of the current tab of window 1'

Google 크롬 에서 활성 URL 가져 오기

osascript -e 'tell app "google chrome" to get the url of the active tab of window 1'

Safari 또는 Google 크롬에서 현재 페이지의 제목 가져 오기

Safari 에서 웹 페이지의 이름 가져 오기

osascript -e 'tell app "safari" to get the name of the current tab of window 1'

Google 크롬 에서 웹 페이지의 제목 가져 오기

osascript -e 'tell app "google chrome" to get the title of the active tab of window 1'

AppleScript를 셸 함수로 사용

단 한 줄의 AppleScript 코드에만 국한되지 않습니다. 여기에서는 앞의 두 예제를 하나의 함수로 결합합니다.

#!/bin/bash    

pageinfo() {
  osascript -e \
  'tell app "safari" 
    tell the current tab of window 1
      return {url & "\n" & name}
    end tell
  end tell'
}


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow