Skip to content

Commit ddf4542

Browse files
committed
feature: cloudcmd: add ability to hide dot files (#307)
1 parent 9dbd812 commit ddf4542

File tree

11 files changed

+203
-126
lines changed

11 files changed

+203
-126
lines changed

HELP.md

Lines changed: 124 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -59,78 +59,79 @@ cloudcmd
5959

6060
Cloud Commander supports the following command-line parameters:
6161

62-
|Parameter |Operation
63-
|:------------------------------|:------------------------------
64-
| `-h, --help` | display help and exit
65-
| `-v, --version` | display version and exit
66-
| `-s, --save` | save configuration
67-
| `-o, --online` | load scripts from remote servers
68-
| `-a, --auth` | enable authorization
69-
| `-u, --username` | set username
70-
| `-p, --password` | set password
71-
| `-c, --config` | configuration file path
72-
| `--show-config` | show config values
73-
| `--show-file-name` | show file name in view and edit
74-
| `--editor` | set editor: "dword", "edward" or "deepword"
75-
| `--packer` | set packer: "tar" or "zip"
76-
| `--root` | set root directory
77-
| `--prefix` | set url prefix
78-
| `--prefix-socket` | set prefix for url connection
79-
| `--port` | set port number
80-
| `--confirm-copy` | confirm copy
81-
| `--confirm-move` | confirm move
82-
| `--open` | open web browser when server starts
83-
| `--name` | set tab name in web browser
84-
| `--one-file-panel` | show one file panel
85-
| `--keys-panel` | show keys panel
86-
| `--contact` | enable contact
87-
| `--config-dialog` | enable config dialog
88-
| `--config-auth` | enable auth change in config dialog
89-
| `--console` | enable console
90-
| `--sync-console-path` | sync console path
91-
| `--terminal` | enable terminal
92-
| `--terminal-path` | set terminal path
93-
| `--terminal-command` | set command to run in terminal (shell by default)
94-
| `--terminal-auto-restart` | restart command on exit
95-
| `--vim` | enable vim hot keys
96-
| `--columns` | set visible columns
97-
| `--theme` | set theme 'light' or 'dark'"
98-
| `--export` | enable export of config through a server
99-
| `--export-token` | authorization token used by export server
100-
| `--import` | enable import of config
101-
| `--import-token` | authorization token used to connect to export server
102-
| `--import-url` | url of an import server
103-
| `--import-listen` | enable listen on config updates from import server
104-
| `--dropbox` | enable dropbox integration
105-
| `--dropbox-token` | set dropbox token
106-
| `--log` | enable logging
107-
| `--no-show-config` | do not show config values
108-
| `--no-server` | do not start server
109-
| `--no-auth` | disable authorization
110-
| `--no-online` | load scripts from local server
111-
| `--no-open` | do not open web browser when server started
112-
| `--no-name` | set default tab name in web browser
113-
| `--no-keys-panel` | hide keys panel
114-
| `--no-one-file-panel` | show two file panels
115-
| `--no-confirm-copy` | do not confirm copy
116-
| `--no-confirm-move` | do not confirm move
117-
| `--no-config-dialog` | disable config dialog
118-
| `--no-config-auth` | disable auth change in config dialog
119-
| `--no-console` | disable console
120-
| `--no-sync-console-path` | do not sync console path
121-
| `--no-contact` | disable contact
122-
| `--no-terminal` | disable terminal
123-
| `--no-terminal-command` | set default shell to run in terminal
124-
| `--no-terminal-auto-restart` | do not restart command on exit
125-
| `--no-vim` | disable vim hot keys
62+
| Parameter |Operation
63+
|:-----------------------------|:------------------------------
64+
| `-h, --help` | display help and exit
65+
| `-v, --version` | display version and exit
66+
| `-s, --save` | save configuration
67+
| `-o, --online` | load scripts from remote servers
68+
| `-a, --auth` | enable authorization
69+
| `-u, --username` | set username
70+
| `-p, --password` | set password
71+
| `-c, --config` | configuration file path
72+
| `--show-config` | show config values
73+
| `--show-dot-files` | show dot files
74+
| `--show-file-name` | show file name in view and edit
75+
| `--editor` | set editor: "dword", "edward" or "deepword"
76+
| `--packer` | set packer: "tar" or "zip"
77+
| `--root` | set root directory
78+
| `--prefix` | set url prefix
79+
| `--prefix-socket` | set prefix for url connection
80+
| `--port` | set port number
81+
| `--confirm-copy` | confirm copy
82+
| `--confirm-move` | confirm move
83+
| `--open` | open web browser when server starts
84+
| `--name` | set tab name in web browser
85+
| `--one-file-panel` | show one file panel
86+
| `--keys-panel` | show keys panel
87+
| `--contact` | enable contact
88+
| `--config-dialog` | enable config dialog
89+
| `--config-auth` | enable auth change in config dialog
90+
| `--console` | enable console
91+
| `--sync-console-path` | sync console path
92+
| `--terminal` | enable terminal
93+
| `--terminal-path` | set terminal path
94+
| `--terminal-command` | set command to run in terminal (shell by default)
95+
| `--terminal-auto-restart` | restart command on exit
96+
| `--vim` | enable vim hot keys
97+
| `--columns` | set visible columns
98+
| `--theme` | set theme 'light' or 'dark'"
99+
| `--export` | enable export of config through a server
100+
| `--export-token` | authorization token used by export server
101+
| `--import` | enable import of config
102+
| `--import-token` | authorization token used to connect to export server
103+
| `--import-url` | url of an import server
104+
| `--import-listen` | enable listen on config updates from import server
105+
| `--dropbox` | enable dropbox integration
106+
| `--dropbox-token` | set dropbox token
107+
| `--log` | enable logging
108+
| `--no-show-config` | do not show config values
109+
| `--no-server` | do not start server
110+
| `--no-auth` | disable authorization
111+
| `--no-online` | load scripts from local server
112+
| `--no-open` | do not open web browser when server started
113+
| `--no-name` | set default tab name in web browser
114+
| `--no-keys-panel` | hide keys panel
115+
| `--no-one-file-panel` | show two file panels
116+
| `--no-confirm-copy` | do not confirm copy
117+
| `--no-confirm-move` | do not confirm move
118+
| `--no-config-dialog` | disable config dialog
119+
| `--no-config-auth` | disable auth change in config dialog
120+
| `--no-console` | disable console
121+
| `--no-sync-console-path` | do not sync console path
122+
| `--no-contact` | disable contact
123+
| `--no-terminal` | disable terminal
124+
| `--no-terminal-command` | set default shell to run in terminal
125+
| `--no-terminal-auto-restart` | do not restart command on exit
126+
| `--no-vim` | disable vim hot keys
126127
| `--no-themes` | set default visible themes
127-
| `--no-export` | disable export config through a server
128-
| `--no-import` | disable import of config
129-
| `--no-import-listen` | disable listen on config updates from import server
130-
| `--no-show-file-name` | do not show file name in view and edit
131-
| `--no-dropbox` | disable dropbox integration
132-
| `--no-dropbox-token` | unset dropbox token
133-
| `--no-log` | disable logging
128+
| `--no-export` | disable export config through a server
129+
| `--no-import` | disable import of config
130+
| `--no-import-listen` | disable listen on config updates from import server
131+
| `--no-show-file-name` | do not show file name in view and edit
132+
| `--no-dropbox` | disable dropbox integration
133+
| `--no-dropbox-token` | unset dropbox token
134+
| `--no-log` | disable logging
134135

135136
For options not specified by command-line parameters, Cloud Commander then reads configuration data from `~/.cloudcmd.json`. It uses port `8000` by default.
136137

@@ -152,56 +153,57 @@ Then, start the server again with `cloudcmd` and reload the page.
152153

153154
## Hot keys
154155

155-
|Key |Operation
156-
|:----------------------|:--------------------------------------------
157-
| `F1` | help
158-
| `F2` | show `user menu`
159-
| `F3` | view, change directory
160-
| `Shift + F3` | view raw file, change directory
161-
| `F4` | edit
162-
| `F5` | copy
163-
| `Alt` + `F5` | pack
164-
| `F6` | rename/move
165-
| `Shift` + `F6` | rename current file
166-
| `F7` | new directory
167-
| `Shift + F7` | new file
168-
| `F8`, `Delete` | remove
169-
| `Shift + Delete` | remove without prompt
170-
| `F9` | menu
171-
| `Alt` + `F9` | extract
172-
| `F10` | config
173-
| `*` | select/unselect all
174-
| `+` | expand selection
175-
| `-` | shrink selection
176-
| `:` | open Command Line
177-
| `Ctrl + X` | cut to buffer
178-
| `Ctrl + C` | copy to buffer
179-
| `Ctrl + V` | paste from buffer
180-
| `Ctrl + Z` | clear buffer
181-
| `Ctrl + P` | copy path
182-
| `Ctrl + R` | refresh
183-
| `Ctrl + D` | clear local storage
184-
| `Ctrl + A` | select all files in a panel
185-
| `Ctrl + M` | [rename selected files](https://github.com/coderaiser/cloudcmd/releases/tag/v12.1.0) in editor
186-
| `Ctrl + U` | swap panels
187-
| `Ctrl + F3` | sort by name
188-
| `Ctrl + F5` | sort by date
189-
| `Ctrl + F6` | sort by size
190-
| `Up`, `Down` | file system navigation
191-
| `Enter` | change directory/view file
192-
| `Alt + Left/Right` | show content of directory under cursor in target panel
193-
| `Alt + G` | go to directory
194-
| `Ctrl + \` | go to the root directory
195-
| `Tab` | move via panels
196-
| `Page Up` | up on one page
197-
| `Page Down` | down on one page
198-
| `Home` | to begin of list
199-
| `End` | to end of list
200-
| `Space` | select current file (and get size of directory)
201-
| `Insert` | select current file (and move to next)
202-
| `F9` | context menu
203-
| `~` | console
204-
| `Esc` | toggle vim hotkeys (`file manager`, `editor`)
156+
| Key |Operation
157+
|:---------------------|:--------------------------------------------
158+
| `F1` | help
159+
| `F2` | show `user menu`
160+
| `F3` | view, change directory
161+
| `Shift + F3` | view raw file, change directory
162+
| `F4` | edit
163+
| `F5` | copy
164+
| `Alt` + `F5` | pack
165+
| `F6` | rename/move
166+
| `Shift` + `F6` | rename current file
167+
| `F7` | new directory
168+
| `Shift + F7` | new file
169+
| `F8`, `Delete` | remove
170+
| `Shift + Delete` | remove without prompt
171+
| `F9` | menu
172+
| `Alt` + `F9` | extract
173+
| `F10` | config
174+
| `*` | select/unselect all
175+
| `+` | expand selection
176+
| `-` | shrink selection
177+
| `:` | open Command Line
178+
| `Ctrl + X` | cut to buffer
179+
| `Ctrl + C` | copy to buffer
180+
| `Ctrl + V` | paste from buffer
181+
| `Ctrl + Z` | clear buffer
182+
| `Ctrl + P` | copy path
183+
| `Ctrl + R` | refresh
184+
| `Ctrl + D` | clear local storage
185+
| `Ctrl + A` | select all files in a panel
186+
| `Ctrl + M` | [rename selected files](https://github.com/coderaiser/cloudcmd/releases/tag/v12.1.0) in editor
187+
| `Ctrl + U` | swap panels
188+
| `Ctrl + F3` | sort by name
189+
| `Ctrl + F5` | sort by date
190+
| `Ctrl + F6` | sort by size
191+
| `Ctrl + Command + .` | show/hide dot files
192+
| `Up`, `Down` | file system navigation
193+
| `Enter` | change directory/view file
194+
| `Alt + Left/Right` | show content of directory under cursor in target panel
195+
| `Alt + G` | go to directory
196+
| `Ctrl + \` | go to the root directory
197+
| `Tab` | move via panels
198+
| `Page Up` | up on one page
199+
| `Page Down` | down on one page
200+
| `Home` | to begin of list
201+
| `End` | to end of list
202+
| `Space` | select current file (and get size of directory)
203+
| `Insert` | select current file (and move to next)
204+
| `F9` | context menu
205+
| `~` | console
206+
| `Esc` | toggle vim hotkeys (`file manager`, `editor`)
205207

206208
### Vim
207209

@@ -398,6 +400,7 @@ Here's a description of all options:
398400
"confirmCopy": true, // confirm copy
399401
"confirmMove": true, // confirm move
400402
"showConfig": false, // show config at startup
403+
"showDotFiles": true, // show dot files
401404
"showFileName": false, // do not show file name in view and edit
402405
"contact": true, // enable contact
403406
"configDialog": true, // enable config dialog

bin/cloudcmd.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const yargsOptions = {
8686
'confirm-copy',
8787
'confirm-move',
8888
'show-config',
89+
'show-dot-files',
8990
'show-file-name',
9091
'vim',
9192
'keys-panel',
@@ -124,6 +125,7 @@ const yargsOptions = {
124125
'export': choose(env.bool('export'), config('export')),
125126

126127
'prefix-socket': config('prefixSocket'),
128+
'show-dot-files': choose(env.bool('show_dot_files'), config('showDotFiles')),
127129
'show-file-name': choose(env.bool('show_file_name'), config('showFileName')),
128130
'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')),
129131
'config-dialog': choose(env.bool('config_dialog'), config('configDialog')),
@@ -189,6 +191,7 @@ async function main() {
189191
config('username', args.username);
190192
config('console', args.console);
191193
config('syncConsolePath', args.syncConsolePath);
194+
config('showDotFiles', args.showDotFiles);
192195
config('showFileName', args.showFileName);
193196
config('contact', args.contact);
194197
config('terminal', args.terminal);

client/client.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ function CloudCmdProto(DOM) {
103103
history,
104104
noCurrent,
105105
currentName,
106+
showDotFiles: CloudCmd.config('showDotFiles'),
106107
}, panel);
107108
};
108109

@@ -300,7 +301,6 @@ function CloudCmdProto(DOM) {
300301
* @param options
301302
* { refresh, history } - необходимость обновить данные о каталоге
302303
* @param panel
303-
* @param callback
304304
*
305305
*/
306306
async function ajaxLoad(path, options = {}, panel) {
@@ -348,13 +348,16 @@ function CloudCmdProto(DOM) {
348348

349349
/**
350350
* Функция строит файловую таблицу
351-
* @param json - данные о файлах
351+
* @param data - данные о файлах
352352
* @param panelParam
353-
* @param history
354-
* @param callback
353+
* @param options - history, noCurrent, showDotFiles
355354
*/
356355
async function createFileTable(data, panelParam, options) {
357-
const {history, noCurrent} = options;
356+
const {
357+
history,
358+
noCurrent,
359+
showDotFiles,
360+
} = options;
358361

359362
const names = [
360363
'file',
@@ -385,6 +388,7 @@ function CloudCmdProto(DOM) {
385388
data,
386389
id: panel.id,
387390
prefix,
391+
showDotFiles,
388392
template: {
389393
file,
390394
path,

client/key/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,19 @@ async function switchKey(event) {
509509
event.preventDefault();
510510
}
511511

512+
break;
513+
514+
case KEY.DOT:
515+
if (meta && shift) {
516+
const showDotFiles = !CloudCmd.config('showDotFiles');
517+
CloudCmd._config('showDotFiles', showDotFiles);
518+
CloudCmd.refresh();
519+
await DOM.RESTful.Config.write({
520+
showDotFiles,
521+
});
522+
}
523+
512524
break;
513525
}
514526
}
527+

common/cloudfunc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const Path = store();
1616

1717
Path('/');
1818

19+
const filterOutDotFiles = ({showDotFiles}) => ({name}) => {
20+
if (showDotFiles)
21+
return true;
22+
23+
return !name.startsWith('.');
24+
};
25+
1926
module.exports.FS = FS;
2027
module.exports.apiURL = '/api/v1';
2128
module.exports.MAX_FILE_SIZE = 500 * 1024;
@@ -118,6 +125,7 @@ module.exports.buildFromJSON = (params) => {
118125
template,
119126
sort = 'name',
120127
order = 'asc',
128+
showDotFiles,
121129
} = params;
122130

123131
const templateFile = template.file;
@@ -195,6 +203,7 @@ module.exports.buildFromJSON = (params) => {
195203
}
196204

197205
fileTable += files
206+
.filter(filterOutDotFiles({showDotFiles}))
198207
.map(updateField)
199208
.map((file) => {
200209
const name = encode(file.name);

0 commit comments

Comments
 (0)