Open an .html file with default browser using Bash on Mac

前端 未结 8 1639
陌清茗
陌清茗 2020-12-13 17:17

So, this is what I need :

Let\'s say I have an index.html file.

How do I tell the terminal to open it using the default browser?

(Using

8条回答
  •  隐瞒了意图╮
    2020-12-13 17:31

    To open the filename.html in the default browser use :

    open filename.html
    

    open is a very good command as well as a feature of Mac OS that makes me fall in love with it more deeper. It automatically chooses the appropriate default app to open the file.

    And in case you want to open a file in your desired app rather then default :

    open -a /Applications/Google\ Chrome.app filename.html
    

    The backslash \ after Google is used to escape the space character.

    Alternatively you can write :

    open -a "/Applications/Google Chrome.app" filename.html
    

    Hope this helps you ( I know I am very late ) and others !!!.

提交回复
热议问题