1

Is it possible via the command line to get the current open tab url in a browser? It can be any Mac browser. I was hoping when I find a good website I'm on I can just pop over to my shell and run a bash script to put the url in a variable so then I can do things later with it. Is this possible? If it is not possible peeking into a browser, would it be possible to start the browser via command line and then be able to access the current tab url?

1 Answer 1

2

Not sure if this helps you, but I think you can accomplish this in AppleScript along these lings:

property theURL : ""
tell application "Safari"
    set theURL to URL of current tab of window 1
end tell
Sign up to request clarification or add additional context in comments.

1 Comment

Dr Drang actually made a post today which may also be relevant to this. About half way down he shows how to execute a AppleScript as a python subprocess (literally using the same example as here) which could let you execute the code from a bash shell script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.