0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Mac] ターミナルからChromeを起動する

Posted at

はじめに

Mac book proのターミナルからChromeを起動したかったので起動方法とコマンドのエイリアスの設定方法を備忘録として残します。

ターミナルからChromeを起動する

ターミナルを開きopenコマンドで'Google Chrome'アプリを起動します。
引数にwebページのURLを渡してあげればChromeが開きwebページが表示されます。

ターミナル
$ open -a 'Google Chrome' 'https://google.com'

ローカルPC内の.htmlファイルを引数として渡すとwebページ同様Chromeで表示されます。

ターミナル
$ open -a 'Google Chrome' '~/sample.html'

コマンドのエイリアスを設定する

コマンドのエイリアスを設定するには.zshrcにエイリアスの設定を記述します。(使用しているシェルの種類に応じて読み替えてください)
今回はchromeというコマンド名で設定します。

ターミナル
# テキストエディターでzshrcを開きます
$ vi .zshrc
ターミナル
# zshrcが開いたら下記を追記する
alias chrome="open -a 'Google Chrome'"
ターミナル
# ターミナルに戻ったらzshrcを再度読み込む
$ source .zshrc

# chromeコマンドを起動してみる
$ chrome 'https://google.com'

おわりに

時々ターミナルからChromeを開きたくなるので設定したくなり調べたら意外と簡単でした。
今回zshと記載しましたがbashでも変わらないと思います。

参考サイト

今回参考にさせてもらったサイトです。
ありがとうございました。

MacのターミナルからChromeを開いてサイトにアクセスする

【初心者向け】エイリアスの設定方法

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?