Skip to content
Snippets Groups Projects
Commit b55c2544 authored by Guy Zana's avatar Guy Zana
Browse files

cli: cd command - allow tab completion for subdirectories as well

Example:

[/]$ cd
dev tmp tests   usr etc console java
[/]$ cd usr/{TAB}
lib share
[/]$ cd usr/lib/{TAB}
jvm jni
[/]$ cd usr/lib/jv{TAB}m/{TAB}jre/{TAB}lib/{TAB}amd64/{ENTER}
headless    server
[/usr/lib/jvm/jre/lib/amd64]$
parent 39331620
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,34 @@ var cd = { ...@@ -39,7 +39,34 @@ var cd = {
}, },
tab: function(inp) { tab: function(inp) {
return (ls.ls_dirs()); if (inp.length == 1) {
return (ls.ls_dirs());
}
if (inp.length > 2) {
return ([]);
}
arg = inp[1];
if (arg.indexOf('/') == -1) {
return (ls.ls_dirs());
}
last_slash = arg.lastIndexOf('/');
dir = arg.substring(0, last_slash);
dirs = ls.ls_dirs(dir);
arr = [];
for (var i=0; i<dirs.length; i++) {
arr[i] = dir + '/' + dirs[i];
}
return (arr);
},
tab_pretty: function(arg) {
last_slash = arg.lastIndexOf('/');
return (arg.substring(last_slash+1));
}, },
tab_final: function(found_match) { tab_final: function(found_match) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment