Skip to content

Useful script to open and interact with Safari from terminal on MacOS. Simple tweak to use this script also with other web browsers e.g. Google Chrome, Mozilla Firefox, Opera.

Notifications You must be signed in to change notification settings

antoniolanza1996/openSafariFromTerminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Useful script to open and interact with Safari from terminal on MacOS

3 types of usage:

  1. safari.sh ----> simply open Safari
  2. safari.sh --url URL_PARAM ----> open a tab in Safari with the site specified in URL_PARAM
  3. safari.sh YOUR_QUERY_SEPARATED_BY_SPACE ----> open Safari and search "YOUR_QUERY_SEPARATED_BY_SPACE" on Google (NOTE: if your query contains symbols which are Shell operators (e.g. (, ), &, ', >), you should put it in quotes as you can see in example usage 3.ii)

Examples of usage:

  1. safari.sh ----> open Safari
  2. safari.sh --url www.github.com ----> open https://www.github.com on Safari
    1. safari.sh something to search on Google ----> find "something to search on Google" on Google
    2. safari.sh "Where there's a will there's a way (proverb)" ----> find "Where there's a will there's a way (proverb)" on Google

Support for other web browsers

If you usually use another web browser on your Mac, you can easily adapt my script by changing BROWSER_PATH variable with the correct web browser installation path. For example:

Google Chrome

BROWSER_PATH="/Applications/Google Chrome.app"

Mozilla Firefox

BROWSER_PATH="/Applications/Firefox.app"

Opera

BROWSER_PATH="/Applications/Opera.app"

Extra

See https://github.com/antoniolanza1996/scripts_and_dotfiles/tree/main/bash_scripts for other useful bash scripts for MacOS.

About

Useful script to open and interact with Safari from terminal on MacOS. Simple tweak to use this script also with other web browsers e.g. Google Chrome, Mozilla Firefox, Opera.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages