Lesson

Use a Zsh Function With AppleScript to Get the URL From Chrome

AppleScript is a powerful and strange language that allows you to interact with apps in a wide variety of ways. One feature it enables is the ability to get the URL from Chrome so that you can take the URL and do whatever you want with it.

Duration
3 min
Access
Free
Transcript
Available

AppleScript is a powerful and strange language that allows you to interact with apps in a wide variety of ways. One feature it enables is the ability to get the URL from Chrome so that you can take the URL and do whatever you want with it.

Terminal
clone(){
  cd ~/projects
  url=$(osascript -e 'tell application "Google Chrome" to return URL of active tab of front window')

  repo=${url:19}
  name=${repo:t}

  git clone git@github.com:$repo && code $name
}