diff --git a/blash.css b/blash.css index a3a5b17..1ab7fd8 100644 --- a/blash.css +++ b/blash.css @@ -13,6 +13,7 @@ input.promptInput color : #888; font-family : Terminus, courier, monospace, fixed; font-size : 13px; + width : 400px; } div#blashWindow @@ -35,9 +36,14 @@ span.directory color : #2553ee; } -.file +a { - color : #4f4; + color : green; +} + +a:visited +{ + color : green; } span.syntax diff --git a/blash.js b/blash.js index 9f54b7e..9687a31 100644 --- a/blash.js +++ b/blash.js @@ -35,6 +35,9 @@ function blash () /** Counter of the open tags when replacing the colours in the command prompt */ this.__open_spans = 0; + + /** Check if this is the first command given in this session (for fixing
stuff) */ + this.__first_cmd = true; /**************************************/ this.loadCommand = function ( cmd ) @@ -133,7 +136,22 @@ function blash () this.window.removeChild ( this.prompt ); this.window.removeChild ( this.cmdOut ); - this.window.innerHTML += value + '
' + out + text; + + if ( this.__first_cmd ) + { + this.window.innerHTML += value + '
' + out + text; + this.__first_cmd = false; + } else { + if ( out ) + { + if ( out.match ( /^\s*\s*/ )) + { + out = ''; + } + } + + this.window.innerHTML += value + '
' + out + text; + } this.prompt = document.createElement ( 'input' ); this.prompt.setAttribute ( 'name', 'blashPrompt' ); diff --git a/blash.json b/blash.json index d5abcc2..1c07349 100644 --- a/blash.json +++ b/blash.json @@ -9,7 +9,7 @@ "extent permitted by law.
" + "Type 'man blash' for help on usage and available commands

", - "user" : "blacklight", + "user" : "guest", "machine" : "localhost", "shellName" : "blash", "basepath" : "/", @@ -54,6 +54,7 @@ { "path" : "/home/blacklight/mbox", "type" : "file", + "content" : "No new mail", }, { "path" : "/etc", @@ -69,9 +70,11 @@ "commands" : [ "cat", "cd", + "find", "ls", "man", "pwd", + "whoami", ], } diff --git a/commands/find.json b/commands/find.json new file mode 100644 index 0000000..4f1a2a5 --- /dev/null +++ b/commands/find.json @@ -0,0 +1,48 @@ +{ + "name" : "find", + + "info" : { + "syntax" : "find <text|regex>", + "brief" : "Search for file or directories in the root hierarchy", + }, + + "action" : function ( arg ) + { + var out = ''; + + if ( !arg || arg.length == 0 ) + { + return "Argument required
\n"; + } + + if ( arg.match ( "^['\"](.*)['\"]$" )) + { + arg = RegExp.$1; + } + + var re = new RegExp ( arg ); + + for ( var i in shell.json.directories ) + { + var dir = shell.json.directories[i]; + + if ( dir.path.match ( re )) + { + + if ( dir.type == 'directory' ) + { + out += '' + dir.path + "
\n"; + } else if ( dir.type == 'file' && dir.href ) { + out += '' + + '' + + dir.path + "
\n"; + } else { + out += dir.path + "
\n"; + } + } + } + + return out; + }, +} + diff --git a/commands/ls.json b/commands/ls.json index eff8d39..373845d 100644 --- a/commands/ls.json +++ b/commands/ls.json @@ -114,6 +114,17 @@ if ( !exists ) { + for ( var i=0; i < shell.json.directories.length; i++ ) + { + var dir = shell.json.directories[i]; + arg = arg.replace ( /\/+$/, '' ); + + if ( dir.path.match ( arg )) + { + return ''; + } + } + var re = null; if ( arg.match ( /^\// )) diff --git a/commands/whoami.json b/commands/whoami.json new file mode 100644 index 0000000..2e1dbf0 --- /dev/null +++ b/commands/whoami.json @@ -0,0 +1,21 @@ +{ + "name" : "whoami", + + "info" : { + "syntax" : "whoami", + "brief" : "Print effective userid", + }, + + "action" : function ( arg ) + { + var out = ''; + + if ( arg ) + { + return "whoami: extra operand `" + arg + "'
\n"; + } + + return shell.json.user + "
\n"; + }, +} +