├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── cli.js ├── config-hyperterm.gif ├── hyperterm.mock.js ├── index.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '6' 4 | - '5' 5 | - '4' 6 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | var meow = require('meow'); 5 | var configHyperterm = require('./')(); 6 | 7 | 8 | const getField = (input, field) => input.map(o => o[field]); 9 | 10 | var cli = meow([ 11 | 'Usage', 12 | ' $ config-hyperterm', 13 | '', 14 | 'Options', 15 | ' --plugins List of plugins that are already present.', 16 | ' --local-plugins List of plugins that are already present.', 17 | ' plugin [name] The plugin name to add.', 18 | ' local-plugin [name] The plugin name to add.', 19 | ' font-size [value] Get or set the font-size.', 20 | ' font-family [value] Get or set the font-family.', 21 | ' cursor-color [value] Get or set the cursor-color.', 22 | ' fg-color [value] Get or set the foregroundColor.', 23 | ' bg-color [value] Get or set the backgroundColor', 24 | ' css [value] Get or set the CSS.', 25 | ' term-css [value] Get or set the termCSS.', 26 | ' colors [value] Get or set the colors.', 27 | '', 28 | 'Examples', 29 | '$ config-hyperterm --plugins', 30 | "[ 'hyperterm-snazzy', 'hypercwd', 'hypertheme' ]", 31 | '$ config-hyperterm --local-plugins', 32 | '[]' 33 | ]); 34 | 35 | 36 | if (!(Object.keys(cli.flags).length) && cli.input.length < 1) { 37 | cli.showHelp(); 38 | process.exit(1); 39 | } 40 | 41 | if (cli.input.length === 1) { 42 | console.log(configHyperterm.get(cli.input[0])); 43 | } 44 | 45 | if (cli.input.length === 2) { 46 | configHyperterm.set(cli.input[0], cli.input[1]); 47 | } 48 | 49 | if (Object.keys(cli.flags).length > 0) { 50 | if (cli.flags.plugins) { 51 | console.log(configHyperterm.get('plugins')); 52 | } 53 | else if (cli.flags.localPlugins) { 54 | console.log(configHyperterm.get('localPlugins')); 55 | } else { 56 | console.log(`No such flag ${Object.keys(cli.flags).join(' ')}`); 57 | } 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /config-hyperterm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemanth/config-hyperterm/c13b7f01b155a6639ba65a8fefb7f25217952c3d/config-hyperterm.gif -------------------------------------------------------------------------------- /hyperterm.mock.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | config: { 3 | // default font size in pixels for all tabs 4 | fontSize: 12, 5 | 6 | // font family with optional fallbacks 7 | fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace', 8 | 9 | // terminal cursor background color (hex) 10 | cursorColor: '#F81CE5', 11 | 12 | // color of the text 13 | foregroundColor: '#fff', 14 | 15 | // terminal background color 16 | backgroundColor: '#000', 17 | 18 | // border color (window, tabs) 19 | borderColor: '#333', 20 | 21 | // custom css to embed in the main window 22 | css: '', 23 | 24 | // custom padding (css format, i.e.: `top right bottom left`) 25 | termCSS: '', 26 | 27 | // custom padding 28 | padding: '12px 14px', 29 | 30 | // some color overrides. see http://bit.ly/29k1iU2 for 31 | // the full list 32 | colors: [ 33 | '#000000', 34 | '#ff0000', 35 | '#33ff00', 36 | '#ffff00', 37 | '#0066ff', 38 | '#cc00ff', 39 | '#00ffff', 40 | '#d0d0d0', 41 | '#808080', 42 | '#ff0000', 43 | '#33ff00', 44 | '#ffff00', 45 | '#0066ff', 46 | '#cc00ff', 47 | '#00ffff', 48 | '#ffffff' 49 | ] 50 | }, 51 | 52 | // a list of plugins to fetch and install from npm 53 | // format: [@org/]project[#version] 54 | // examples: 55 | // `hypersolar` 56 | // `@company/project` 57 | // `project#1.0.1` 58 | plugins: ['hyperterm-snazzy','hypercwd', 'hypertheme'], 59 | 60 | // in development, you can create a directory under 61 | // `~/.hyperterm_plugins/local/` and include it here 62 | // to load it and avoid it being `npm install`ed 63 | localPlugins: [] 64 | }; 65 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const camelCase = require('camelcase'); 3 | const R = require('ramda'); 4 | const writeFileSync = require('fs').writeFileSync; 5 | const shortHandMap = { 6 | 'bg-color': 'backgroundColor', 7 | 'fg-color': 'foregroundColor', 8 | 'term-css': 'term-CSS' 9 | } 10 | 11 | let hyperTermconfig, configPath; 12 | 13 | const requireConfig = hyperTermconfigPath => { 14 | configPath = require('expand-tilde')(hyperTermconfigPath || '~/.hyper.js'); 15 | try { 16 | hyperTermconfig = require(configPath); 17 | } catch(e) { 18 | console.error('Could not find `~/.hyper.js`, please make sure you have installed hyperterm!'); 19 | process.exit(-1); 20 | } 21 | } 22 | 23 | const getConfigAtttr = prop => { 24 | var confLens = R.lensProp(shortHandMap[prop] || camelCase(prop)); 25 | return R.view(confLens, hyperTermconfig.config) || 26 | R.view(confLens, hyperTermconfig) || 27 | unknownProp(prop); 28 | } 29 | 30 | const setConfigAttr = (prop,val) => { 31 | var confLens = R.lensProp(shortHandMap[prop] || camelCase(prop)); 32 | if( R.view(confLens, hyperTermconfig.config)){ 33 | hyperTermconfig.config = R.set(confLens, val, hyperTermconfig.config); 34 | } else if (R.view(confLens, hyperTermconfig)){ 35 | hyperTermconfig = R.set(confLens, val, hyperTermconfig); 36 | } else { 37 | console.log(unknownProp(prop)); 38 | } 39 | writeFileSync(configPath,`module.exports=${JSON.stringify(hyperTermconfig, null, 2)}`, {encoding:'utf-8'}); 40 | } 41 | 42 | const unknownProp = prop => `Undefined property: ${prop} check --help`; 43 | 44 | const getVal = (prop) => getConfigAtttr(prop); 45 | 46 | const setVal = (prop, val) => setConfigAttr(prop, val); 47 | 48 | 49 | module.exports = hyperTermconfigPath => { 50 | requireConfig(hyperTermconfigPath); 51 | return { 52 | get: (prop) => { 53 | return getVal(prop); 54 | }, 55 | set: (prop, val) => { 56 | return setVal(prop, val); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Hemanth.HM (h3manth.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "config-hyperterm", 3 | "version": "1.0.1", 4 | "description": "Easily set/get `hyperterm` config.", 5 | "license": "MIT", 6 | "repository": "hemanth/config-hyperterm", 7 | "author": { 8 | "name": "Hemanth.HM", 9 | "email": "hemanth.hm@gmail.com", 10 | "url": "h3manth.com" 11 | }, 12 | "bin": "cli.js", 13 | "engines": { 14 | "node": ">=0.10.0" 15 | }, 16 | "scripts": { 17 | "test": "ava" 18 | }, 19 | "files": [ 20 | "index.js", 21 | "cli.js" 22 | ], 23 | "keywords": [ 24 | "cli-app", 25 | "cli", 26 | "hyperterm", 27 | "config" 28 | ], 29 | "dependencies": { 30 | "camelcase": "^3.0.0", 31 | "expand-tilde": "^1.2.2", 32 | "meow": "^3.7.0", 33 | "ramda": "^0.21.0" 34 | }, 35 | "devDependencies": { 36 | "ava": "^0.14.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # config-hyperterm [![Build Status](https://travis-ci.org/hemanth/config-hyperterm.svg?branch=master)](https://travis-ci.org/hemanth/config-hyperterm) 2 | 3 | > Easily set/get `hyperterm` config. 4 | 5 | 6 | ## Install 7 | 8 | ``` 9 | $ npm install --save config-hyperterm 10 | ``` 11 | 12 | 13 | ## Usage 14 | 15 | ```js 16 | const configHyperterm = require('./')('~/.hyperterm.js'); 17 | 18 | configHyperterm.get('plugins'); //[ 'hyperterm-snazzy', 'hypercwd', 'hypertheme' ] 19 | 20 | configHyperterm.set('plugins', 'hypercwd'); //WIP 21 | ``` 22 | 23 | 24 | ## API 25 | 26 | ### configHyperterm(path) 27 | 28 | #### path 29 | 30 | Type: `Object` 31 | 32 | HyperTerm Configuration path, defaults to `~/.hyperterm.js` 33 | 34 | ## CLI 35 | 36 | ``` 37 | $ npm install --global config-hyperterm 38 | ``` 39 | 40 | ``` 41 | $ config-hyperterm 42 | 43 | Easily set/get `hyperterm` config. 44 | 45 | Usage 46 | $ config-hyperterm 47 | 48 | Options 49 | --plugins List of plugins that are already present. 50 | --local-plugins List of plugins that are already present. 51 | plugin [name] The plugin name to add. 52 | local-plugin [name] The plugin name to add. 53 | font-size [value] Get or set the font-size. 54 | font-family [value] Get or set the font-family. 55 | cursor-color [value] Get or set the cursor-color. 56 | fg-color [value] Get or set the foregroundColor. 57 | bg-color [value] Get or set the backgroundColor 58 | css [value] Get or set the CSS. 59 | term-css [value] Get or set the termCSS. 60 | colors [value] Get or set the colors. 61 | 62 | Examples 63 | $ config-hyperterm --plugins 64 | [ 'hyperterm-snazzy', 'hypercwd', 'hypertheme' ] 65 | $ config-hyperterm --local-plugins 66 | [] 67 | 68 | ``` 69 | 70 | __GIF FTW:__ 71 | 72 | ![config-hyperterm](./config-hyperterm.gif) 73 | 74 | 75 | ## License 76 | 77 | MIT © [Hemanth.HM](https://h3manth.com) 78 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import fn from './'; 3 | 4 | test('title', t => { 5 | t.is(fn('./hyperterm.mock.js').get('plugins')[0], 'hyperterm-snazzy'); 6 | }); 7 | --------------------------------------------------------------------------------