diff --git a/lib/actions/ui.js b/lib/actions/ui.js index f9b46c28..9d17020c 100644 --- a/lib/actions/ui.js +++ b/lib/actions/ui.js @@ -1,5 +1,6 @@ import {EOL} from 'os'; +import {remote} from 'electron'; import * as shellEscape from 'php-escape-shell'; import last from '../utils/array'; import isExecutable from '../utils/file'; @@ -209,15 +210,29 @@ export function moveTo(i) { }; } +function getEditCommand(shell, isWin) { + if (isWin && shell.includes('bash')) { + return [ + ' nano .hyper.js', + 'echo Attempting to open .hyper.js with nano' + ]; + } else if (isWin) { + return [ + ' start notepad "%userprofile%\\.hyper.js"', + 'echo Attempting to open .hyper.js with notepad' + ]; + } + return [ + // eslint-disable-next-line no-template-curly-in-string + ' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\'', + 'echo Attempting to open ~/.hyper.js with your \\$EDITOR' + ]; +} + export function showPreferences() { - const isWin = process.platform === 'win32'; - // eslint-disable-next-line no-template-curly-in-string - const command = isWin ? ' start notepad "%userprofile%\\.hyper.js"' : ' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\''; - const message = []; - message.push(isWin ? - ' echo Attempting to open ^%userprofile^%\\.hyper.js with notepad' : - ' echo Attempting to open ~/.hyper.js with your \\$EDITOR'); - message.push(' echo If it fails, open it manually with your favorite editor!'); + const plugins = remote.require('./plugins'); + const {shell} = plugins.getDecoratedConfig(); + const message = getEditCommand(shell, process.platform === 'win32'); return dispatch => { dispatch({ @@ -231,7 +246,6 @@ export function showPreferences() { uid, [ ...message, - command, '' ].join(EOL) ));