Last active
August 29, 2015 14:20
-
-
Save daiiz/8fceee8f00699b70ce21 to your computer and use it in GitHub Desktop.
MacでChromeを起動するためのコマンド
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
chrome s
を実行するとchromeがシークレットモードで起動します。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方
www/
にmanifest.json
を持つChromeアプリを起動する方法