diff --git a/README.md b/README.md index 0bab79750e1c88b6a0e0ec4a5462ab127876279d..ed0dbe9e7ca64ed7a400ac6018a02a5376c2f451 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ==================== Open the current [Atom] project in _[GitKraken]_. -This can be activated from the _Packages_ menu, _command palette_, from the context menu on the root project folder in _tree view_, or the git _branch_ indicator in the _status bar_. <kbd>⌥</kbd> or <kbd>⇧</kbd> click will also work here. +This can be activated from the _Packages_ menu, _command palette_, from the context menu on the root project folder in _tree view_, or the git _branch_ indicator in the _status bar_. A modifier key can also be [set][settings] to work here on click. An instance of _GitKraken_ will be spawned for each project by default, but can be configured in the package settings to only ever run a single instance of the application. @@ -23,6 +23,7 @@ License [atom]: https://atom.io [apm]: https://img.shields.io/apm/v/gitkraken.svg?style=flat-square [package]: https://atom.io/packages/gitkraken +[settings]: atom://config/packages/gitkraken [chat]: https://img.shields.io/badge/slack-atom.io-9FD4A9.svg?style=flat-square [#slack]: https://atom-slack.herokuapp.com diff --git a/index.coffee b/index.coffee index bd3ae9636d51279f3528768973db30d22c0a00a7..12cfb181a41e5b04fc1302bcbc803b0e0f291d5f 100644 --- a/index.coffee +++ b/index.coffee @@ -2,12 +2,40 @@ {writeFile, unlink} = require 'fs' SubAtom = require 'sub-atom' +meta = #Key + define: 'https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/metaKey' + key: + switch process.platform + when 'darwin' then "⌘" + when 'linux' then "◆" # Super + when 'win32' then "❖" + +#------------------------------------------------------------------------------- module.exports = #os: process.platform #timeout: #timeout: 10000 #killSignal: 'SIGKILL' + config: + get: (config) -> atom.config.get "gitkraken.#{config}" + + singleInstance: + description: "Limit to a single instance of the application, + else spawn a new instance for each project." + type: 'boolean' + default: false + + statusBar: + description: "Enable a modifier key while clicking the + status bar branch to release GitKraken? + Note that _[`meta`](#{meta.define})_ is <kbd>#{meta.key}</kbd>." + type: 'string' + default: 'shift' + enum: ["alt","shift","meta","ctrl","none"] + +#------------------------------------------------------------------------------- + project: atom.project.getDirectories()[0] ? path: process.cwd() tmp: '/tmp/GitKraken.json' @@ -22,12 +50,12 @@ module.exports = 'gitkraken:release': => @open @project @subs.add atom.packages.onDidActivateInitialPackages => - @subs.add 'status-bar','click', @selector, ({altKey, shiftKey}) => - @open @project if altKey or shiftKey + @subs.add 'status-bar','click', @selector, (key) => + @open @project if key["#{ @config.get 'statusBar'}Key"] #------------------------------------------------------------------------------- open: ({path}) -> - if atom.config.get 'gitkraken.singleInstance' + if @config.get 'singleInstance' exec "pkill GitKraken; sleep .1 && open -Fb #{@id} --args -p '#{path}'" #, @timeout else projects = {} diff --git a/package.json b/package.json index 0bf7077c635ae59bfb69a2354162c5b4819f07fb..aaf95d482f6f069c0962e540ac6f80075fe10d96 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,5 @@ }, "engines": { "atom": "*" - }, - "configSchema": { - "singleInstance": { - "description": "Limit to a single instance of the application, else spawn one per project.", - "type": "boolean", - "default": false - } } }