mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
add config auto-initialization and default config
This commit is contained in:
parent
d3322090a1
commit
adcbbcdc1b
3 changed files with 63 additions and 0 deletions
38
default-config.js
Normal file
38
default-config.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
module.exports = {
|
||||
config: {
|
||||
// default font size for all tabs
|
||||
fontSize: '12px',
|
||||
|
||||
// font family with optional fallbacks
|
||||
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
|
||||
|
||||
// terminal cursor background color
|
||||
cursorColor: '#F81CE5',
|
||||
|
||||
// terminal background color
|
||||
backgroundColor: '#000',
|
||||
|
||||
// some color overrides. see http://bit.ly/29k1iU2 for
|
||||
// the full list
|
||||
colors: [
|
||||
'#000000',
|
||||
'#ff0000',
|
||||
'#33ff00',
|
||||
'#ffff00',
|
||||
'#0066ff',
|
||||
'#cc00ff',
|
||||
'#00ffff',
|
||||
'#d0d0d0',
|
||||
'#808080',
|
||||
'#ff0000',
|
||||
'#33ff00',
|
||||
'#ffff00',
|
||||
'#0066ff',
|
||||
'#cc00ff',
|
||||
'#00ffff',
|
||||
'#ffffff'
|
||||
]
|
||||
},
|
||||
|
||||
plugins: []
|
||||
};
|
||||
3
index.js
3
index.js
|
|
@ -6,6 +6,7 @@ const genUid = require('uid2');
|
|||
const { resolve } = require('path');
|
||||
const isDev = require('electron-is-dev');
|
||||
const AutoUpdater = require('./auto-updater');
|
||||
const initConfig = require('./init-config');
|
||||
|
||||
if (isDev) {
|
||||
console.log('running in dev mode');
|
||||
|
|
@ -30,6 +31,8 @@ app.on('window-all-closed', () => {
|
|||
// terminal is closed
|
||||
});
|
||||
|
||||
const configFile = initConfig();
|
||||
|
||||
let winCount = 0;
|
||||
|
||||
app.on('ready', () => {
|
||||
|
|
|
|||
22
init-config.js
Normal file
22
init-config.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
const { homedir } = require('os');
|
||||
const { resolve } = require('path');
|
||||
const { statSync, readFileSync, writeFileSync } = require('fs');
|
||||
|
||||
module.exports = function initConfig () {
|
||||
const file = resolve(homedir(), '.hyperterm.js');
|
||||
|
||||
try {
|
||||
statSync(file);
|
||||
} catch (err) {
|
||||
console.log('stat error', file, err.message);
|
||||
const defaultConfig = readFileSync(resolve(__dirname, 'default-config.js'));
|
||||
try {
|
||||
console.log('attempting to write default config to', file);
|
||||
writeFileSync(file, defaultConfig);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to write config to ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
};
|
||||
Loading…
Reference in a new issue