diff --git a/blash.js b/blash.js
index fa27ef5..31bfa9a 100644
--- a/blash.js
+++ b/blash.js
@@ -128,16 +128,20 @@ function blash ()
var value = this.prompt.value;
var out = this.cmdOut.innerHTML;
+ var text = ( shell.json.promptText ) ? shell.json.promptText : "[%n@%m %W] $ ";
+ text = shell.unescapePrompt ( text, shell.json.promptSequences );
+
this.window.removeChild ( this.prompt );
this.window.removeChild ( this.cmdOut );
- this.window.innerHTML += value + '
' + out + this.promptText.innerHTML;
+ this.window.innerHTML += value + '
' + out + text;
this.prompt = document.createElement ( 'input' );
this.prompt.setAttribute ( 'name', 'blashPrompt' );
this.prompt.setAttribute ( 'type', 'text' );
this.prompt.setAttribute ( 'class', 'promptInput' );
this.prompt.setAttribute ( 'autocomplete', 'off' );
- this.prompt.setAttribute ( 'onkeyup', 'shell.getKey ( event )' );
+ this.prompt.setAttribute ( 'onkeydown', 'shell.getKey ( event )' );
+ this.prompt.setAttribute ( 'onkeyup', 'this.focus()' );
this.cmdOut = document.createElement ( 'div' );
this.cmdOut.setAttribute ( 'id', 'blashCmdOut' );
@@ -175,6 +179,8 @@ function blash ()
this.prompt.focus();
} else if ( key == 9 ) {
+ this.prompt.focus();
+
if ( this.prompt.value.match ( /\s(.*)$/ ))
{
var arg = RegExp.$1;
@@ -240,6 +246,8 @@ function blash ()
}
}
}
+
+ this.prompt.focus();
}
this.prompt.focus();
@@ -276,6 +284,7 @@ function blash ()
this.unescapePromptSequence = function ( prompt, sequence, text, default_text )
{
var re = new RegExp ( "([^\]?)" + sequence, "g" );
+ prompt.replace ( /%W/g, this.path );
if ( prompt.match ( re ))
{
@@ -284,5 +293,17 @@ function blash ()
return prompt;
}
+
+ this.expandPath = function ( arg )
+ {
+ if ( arg.match ( /^[^\/]/ ))
+ {
+ arg = this.path + '/' + arg;
+ }
+
+ arg = arg.replace ( /\/*$/, '' );
+ arg = arg.replace ( /\/+/, '/' );
+ return arg;
+ }
}
diff --git a/blash.json b/blash.json
index 2b42288..48c1e97 100644
--- a/blash.json
+++ b/blash.json
@@ -33,7 +33,7 @@
"sequence" : "%W",
"default_text" : "~",
"text" : function () {
- return shell.json.basepath;
+ return shell.path;
},
}
],
@@ -51,6 +51,10 @@
"path" : "/home/blacklight",
"type" : "directory",
},
+ {
+ "path" : "/home/blacklight/mbox",
+ "type" : "file",
+ },
{
"path" : "/etc",
"type" : "directory",
diff --git a/commands/ls.json b/commands/ls.json
index d04d696..eff8d39 100644
--- a/commands/ls.json
+++ b/commands/ls.json
@@ -12,22 +12,19 @@
var out = '';
var exists = false;
- arg = arg.replace ( /\/$/, '' );
-
if ( !arg || arg.length == 0 )
{
- var re = new RegExp ( '^' + shell.path + '[^/]+$' );
- } else if ( arg && arg.length > 0 ) {
var re = null;
- if ( arg.match ( /^\// ))
+ if ( shell.path == '/' )
{
- re = new RegExp ( '^' + arg + '/[^/]+$' );
+ re = new RegExp ( '^' + shell.path + '[^/]+$' );
} else {
- re = new RegExp ( '^' + shell.path +
- (( shell.path == '/' ) ? '' : '/' ) +
- arg + '/[^/]+$' );
+ re = new RegExp ( '^' + shell.path + '/?[^/]+$' );
}
+ } else if ( arg && arg.length > 0 ) {
+ arg = shell.expandPath ( arg );
+ var re = new RegExp ( '^' + arg + '/[^/]+$' );
}
for ( var i=0; i < shell.json.directories.length; i++ )
@@ -38,11 +35,12 @@
{
exists = true;
dir.path.match ( /\/([^\/]+)$/ );
+
dirs.push ({
- "path" : RegExp.$1,
- "type" : dir.type,
- "href" : dir.href,
- });
+ "path" : RegExp.$1,
+ "type" : dir.type,
+ "href" : dir.href,
+ });
}
}
@@ -106,7 +104,7 @@
{
out += '' + dirs[i].path + '*
';
} else {
- out += '' + dirs[i].path + '
';
+ out += dirs[i].path + '
';
}
}
}
diff --git a/index.html b/index.html
index 09b9bf4..2864a51 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@