Skip to content

Instantly share code, notes, and snippets.

@daiiz
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiiz/8fceee8f00699b70ce21 to your computer and use it in GitHub Desktop.
Save daiiz/8fceee8f00699b70ce21 to your computer and use it in GitHub Desktop.
MacでChromeを起動するためのコマンド
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2015 daiz
# Options:
# s: シークレットモードで起動
# run: 開発中のアプリを読み込む
# Usage: $ chrome run /path/to/app/
import os
import sys
import commands
import os.path
def main():
args = sys.argv
# chromeの実行ファイルのパス
path_chrome = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
# 起動オプション
launch_option = ''
# シークレットモードオプション
opt_secret = '--incognito'
# 開発中のアプリのロード(リロード)オプション
opt_devapp = '--load-and-launch-app'
# 開発アプリのパスを取得
app_path = None
if len(args) == 3:
app_path = args[2]
# 起動オプションを解析
if len(args) >= 2:
if 's' in args[1]:
launch_option = '{} {}'.format(launch_option, opt_secret)
if 'run' in args[1] and app_path != None:
launch_option = '{} {}={}'.format(launch_option, opt_devapp, os.path.abspath(app_path))
# 実行コマンドを生成
command = '{}{}'.format(path_chrome, launch_option)
commands.getoutput(command)
if __name__ == "__main__":
main()
@daiiz
Copy link
Author

daiiz commented May 4, 2015

使い方

  • www/manifest.json を持つChromeアプリを起動する方法
chrome run www

@daiiz
Copy link
Author

daiiz commented May 4, 2015

chrome s

を実行するとchromeがシークレットモードで起動します。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment