diff --git a/HELP.md b/HELP.md index 03e9dae2..16289241 100644 --- a/HELP.md +++ b/HELP.md @@ -89,6 +89,7 @@ Cloud Commander supports command line parameters: | `--contact` | enable contact | `--config-dialog` | enable config dialog | `--console` | enable console +| `--sync-console-path` | sync console path | `--terminal` | enable terminal | `--terminal-path` | set terminal path | `--vim` | enable vim hot keys @@ -106,6 +107,7 @@ Cloud Commander supports command line parameters: | `--no-contact` | disable contact | `--no-config-dialog` | disable config dialog | `--no-console` | disable console +| `--no-sync-console-path` | do not sync console path | `--no-terminal` | disable terminal | `--no-vim` | disable vim hot keys | `--no-columns` | set visible default columns @@ -376,6 +378,7 @@ Here is description of options: "contact" : true, /* enable contact */ "configDialog" : true, /* enable config dialog */ "console" : true, /* enable console */ + "syncConsolePath" : false /* do not sync console path */ "terminal" : false, /* disable terminal */ "terminalPath" : '', /* path of a terminal */ "vim" : false, /* disable vim hot keys */ @@ -393,6 +396,7 @@ Some config options can be overridden with `environment variables` such: - `CLOUDCMD_CONTACT` - enable contact - `CLOUDCMD_CONFIG_DIALOG` - enable config dialog - `CLOUDCMD_CONSOLE` - enable console +- `CLOUDCMD_SYNC_CONSOLE_PATH` - sync console path - `CLOUDCMD_TERMINAL` - enable terminal - `CLOUDCMD_TERMINAL_PATH` - set terminal path - `CLOUDCMD_AUTH` - enable authentication diff --git a/app.json b/app.json index 0cbf5b76..7aef64bf 100644 --- a/app.json +++ b/app.json @@ -37,6 +37,11 @@ "value": "true", "required": false }, + "CLOUDCMD_SYNC_CONSOLE_PATH": { + "description": "sync console path", + "value": "false", + "required": false + }, "CLOUDCMD_TERMINAL": { "description": "enable terminal", "value": "true", diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index a1f590a5..55305d93 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -41,6 +41,7 @@ const args = require('minimist')(argv.slice(2), { 'progress', 'config-dialog', 'console', + 'sync-console-path', 'contact', 'terminal', 'one-panel-mode', @@ -68,6 +69,7 @@ const args = require('minimist')(argv.slice(2), { contact : choose(env.bool('contact'), config('contact')), terminal : choose(env.bool('terminal'), config('terminal')), + 'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')), 'config-dialog': choose(env.bool('config_dialog'), config('configDialog')), 'terminal-path': env('terminal_path') || config('terminalPath'), 'one-panel-mode': choose(env.bool('one_panel_mode'), config('onePanelMode')), @@ -114,6 +116,7 @@ function main() { config('username', args.username); config('progress', args.progress); config('console', args.console); + config('syncConsolePath', args['sync-console-path']); config('contact', args.contact); config('terminal', args.terminal); config('terminalPath', args['terminal-path']); diff --git a/client/client.js b/client/client.js index 46604537..fc4bab9f 100644 --- a/client/client.js +++ b/client/client.js @@ -3,13 +3,15 @@ /* global Util, DOM */ const itype = require('itype/legacy'); -const emitify = require('emitify/legacy'); +const Emitify = require('emitify/legacy'); const inherits = require('inherits'); const rendy = require('rendy'); const exec = require('execon'); const Images = require('./dom/images'); const join = require('join-io/www/join'); const jonny = require('jonny/legacy'); +const currify = require('currify/legacy'); + const bind = (f, ...a) => () => f(...a); const { @@ -204,6 +206,7 @@ function CloudCmdProto(Util, DOM) { CloudCmd.PREFIX_URL = prefix + apiURL; CloudCmd.config = (key) => config[key]; + CloudCmd.config.if = currify((key, fn, a) => config[key] && fn(a)); CloudCmd._config = (key, value) => { /* * should be called from config.js only @@ -584,7 +587,7 @@ function CloudCmdProto(Util, DOM) { const path = Info.dirPath || parentDirPath; CloudCmd.loadDir({path}, () => { - const panel = Info.panel; + const {panel} = Info; const current = DOM.getCurrentByName(dir); const first = DOM.getFiles(panel)[0]; diff --git a/client/modules/konsole.js b/client/modules/konsole.js index 6cbead67..e64f9a91 100644 --- a/client/modules/konsole.js +++ b/client/modules/konsole.js @@ -13,18 +13,22 @@ const { CurrentInfo:Info, } = DOM; +const rmLastSlash = (a) => a.replace(/\/$/, '') || '/'; + CloudCmd.Konsole = ConsoleProto; function ConsoleProto() { - const noop = () => {}; + let konsole; + const {config} = CloudCmd; - if (!CloudCmd.config('console')) + const noop = () => {}; + const cd = currify((fn, dir) => fn(`cd ${rmLastSlash(dir)}`)); + + if (!config('console')) return { show: noop }; - const config = CloudCmd.config; - const Name = 'Konsole'; const TITLE = 'Console'; @@ -54,7 +58,7 @@ function ConsoleProto() { }; this.clear = () => { - Console.clear(); + konsole.clear(); }; function getPrefix() { @@ -72,20 +76,38 @@ function ConsoleProto() { }; } + function onPath(path) { + if (Info.dirPath === path) + return; + + CloudCmd.loadDir({ + path, + }); + } + + const getDirPath = () => { + if (config('syncConsolePath')) + return Info.dirPath; + }; + function create(callback) { const options = { + cwd: getDirPath(), env: getEnv(), prefix: getPrefix(), socketPath: CloudCmd.PREFIX, }; - Console(Element, options, (spawn) => { + konsole = Console(Element, options, (spawn) => { spawn.on('connect', exec.with(authCheck, spawn)); + spawn.on('path', config.if('syncConsolePath', onPath)); + + CloudCmd.on('active-dir', config.if('syncConsolePath', cd(spawn.handler))); exec(callback); }); - Console.addShortCuts({ + konsole.addShortCuts({ 'P': () => { const command = Console.getPromptText(); const path = DOM.getCurrentDirPath(); @@ -112,7 +134,7 @@ function ConsoleProto() { CloudCmd.View.show(Element, { afterShow: () => { - Console.focus(); + konsole.focus(); exec(callback); } }); diff --git a/img/screen/config.png b/img/screen/config.png index 66d5616c..8587130e 100644 Binary files a/img/screen/config.png and b/img/screen/config.png differ diff --git a/json/config.json b/json/config.json index 3067282f..3508a98f 100644 --- a/json/config.json +++ b/json/config.json @@ -27,6 +27,7 @@ "configDialog": true, "onePanelMode": false, "console": true, + "syncConsolePath": false, "terminal": false, "terminalPath": "", "showConfig": false, diff --git a/json/help.json b/json/help.json index 9060f1e5..20b0732d 100644 --- a/json/help.json +++ b/json/help.json @@ -22,6 +22,7 @@ "--one-panel-mode ": "set one panel mode", "--config-dialog ": "enable config dialog", "--console ": "enable console", + "--sync-console-path ": "sync console path", "--contact ": "enable contact", "--terminal ": "enable terminal", "--terminal-path ": "set terminal path", @@ -39,6 +40,7 @@ "--no-html-dialogs ": "do not use html dialogs", "--no-config-dialog ": "disable config dialog", "--no-console ": "disable console", + "--no-sync-console-path ": "do not sync console path", "--no-contact ": "disable contact", "--no-terminal ": "disable terminal", "--no-vim ": "disable vim hot keys", diff --git a/man/cloudcmd.1 b/man/cloudcmd.1 index 0c48a41b..4a9a03cd 100644 --- a/man/cloudcmd.1 +++ b/man/cloudcmd.1 @@ -46,6 +46,7 @@ programs in browser from any computer, mobile or tablet device. --contact enable contact --config-dialog enable config dialog --console enable console + --sync-console-path sync console path --terminal enable terminal --terminal-path set terminal path --vim enable vim hot keys @@ -63,6 +64,7 @@ programs in browser from any computer, mobile or tablet device. --no-contact disable contact --no-config-dialog disable config dialog --no-console disable console + --no-sync-console-path do not sync console path --no-terminal disable terminal --no-vim disable vim hot keys --no-columns set visible default columns diff --git a/tmpl/config.hbs b/tmpl/config.hbs index 06c40af0..0fd6adb0 100644 --- a/tmpl/config.hbs +++ b/tmpl/config.hbs @@ -168,4 +168,10 @@ One Panel Mode +