From a9c35ac67feefbb755db55ed740d0f395c22a452 Mon Sep 17 00:00:00 2001 From: Daniel Bayley <daniel.bayley@me.com> Date: Mon, 6 Mar 2017 21:30:20 +0000 Subject: [PATCH] Add branch indicator keybinding setting --- README.md | 3 ++- index.coffee | 34 +++++++++++++++++++++++++++++++--- package.json | 7 ------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0bab797..ed0dbe9 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 bd3ae96..12cfb18 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 0bf7077..aaf95d4 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 - } } } -- GitLab