diff --git a/app/config/config-default.js b/app/config/config-default.js index f1a83b5c..47637cfa 100644 --- a/app/config/config-default.js +++ b/app/config/config-default.js @@ -57,6 +57,9 @@ module.exports = { // custom CSS to embed in the terminal window termCSS: '', + // set custom startup directory (must be an absolute path) + workingDirectory: '', + // if you're using a Linux setup which show native menus, set to false // default: `true` on Linux, `true` on Windows, ignored on macOS showHamburgerMenu: '', diff --git a/app/ui/window.js b/app/ui/window.js index 7ad57903..0f98e57e 100644 --- a/app/ui/window.js +++ b/app/ui/window.js @@ -6,7 +6,7 @@ const fileUriToPath = require('file-uri-to-path'); const isDev = require('electron-is-dev'); const updater = require('../updater'); const toElectronBackgroundColor = require('../utils/to-electron-background-color'); -const {icon, homeDirectory} = require('../config/paths'); +const {icon, cfgDir} = require('../config/paths'); const createRPC = require('../rpc'); const notify = require('../notify'); const fetchNotifications = require('../notifications'); @@ -55,6 +55,14 @@ module.exports = class Window { window.setBackgroundColor(toElectronBackgroundColor(cfg_.backgroundColor || '#000')); }; + // set working directory + let workingDirectory = cfgDir; + if (process.argv[1] && isAbsolute(process.argv[1])) { + workingDirectory = process.argv[1]; + } else if (cfg.workingDirectory && isAbsolute(cfg.workingDirectory)) { + workingDirectory = cfg.workingDirectory; + } + // config changes const cfgUnsubscribe = app.config.subscribe(() => { const cfg_ = app.plugins.getDecoratedConfig(); @@ -106,7 +114,7 @@ module.exports = class Window { { rows: 40, cols: 100, - cwd: process.argv[1] && isAbsolute(process.argv[1]) ? process.argv[1] : homeDirectory, + cwd: workingDirectory, splitDirection: undefined, shell: cfg.shell, shellArgs: cfg.shellArgs && Array.from(cfg.shellArgs)