github atom编辑器前端开发实战(一)- 一键用 chrome 浏览器打开当前编辑的文件,亲测可用

来源:互联网 发布:android仿淘宝首页 编辑:程序博客网 时间:2024/05/16 05:04

Copyright 2016 by 蔡舒啸 保持署名-非商业性使用-相同方式共享 Creative Commons BY-NC-ND 3.0


目录

  • 环境
  • 工具
  • 步骤
  • 感谢 atom-shell-commands 插件的作者韦易笑知乎


环境:

Ubuntu 16.04 64位
github atom 1.8.0
google-chrome 版本 51.0.2704.106 (64-bit) deb格式安装包
node 4.4.4
npm 2.15.1
浏览器可以打开 github.com

工具:

github atom
google-chrome
atom 插件 - atom-shell-commands 插件项目主页https://atom.io/packages/atom-shell-commands

步骤:

打开命令行(在桌面按下 Ctrl+Alt+T),输入

apm install atom-shell-commands

等待一会儿安装成功

按插件主页的教程,用你最喜欢的方式打开文件 ~/.atom/config.cson(修改前先备份),在最后插入以下内容,保存:

  "atom-shell-commands":    commands: [      {        name: "open with chrome"        command: "google-chrome"        arguments: [          "{FileName}"        ]        options:          cwd: "{FileDir}"          keymap: 'ctrl-2'      }    ]

重启atom,新建foo.html,如下:

<html><body><button type="button" onclick="alert('Welcome!')">    点击这里</button><script type="text/javascript">    document.write("Hello, World!");document.write("<h1>This is a heading</h1>");</script></body></html>

保存。然后按快捷键ctrl+2,就用google-chrome打开了foo.html!

我的天!真的启动了google-chrome,打开了foo.html!
这意味着,atom开发前端代码可以随时用chrome调试!太方便了!

感谢 atom-shell-commands 插件的作者韦易笑@知乎!

0 0