|
|
@@ -18,11 +18,12 @@ function pgsh(ev) {
|
|
|
/**
|
|
|
* Variables and Setup
|
|
|
*/
|
|
|
- this.cwd = '/home/pgs'
|
|
|
+ var getHome = function() { return self.su_active ? '/root' : '/home/pgs' }
|
|
|
+ this.cwd = getHome()
|
|
|
var getPrompt = function() {
|
|
|
if (self.su_active) {
|
|
|
- return '<span style="color:purple">root </span>' +
|
|
|
- '<span style="color:tomato">' + self.cwd + ' </span>' +
|
|
|
+ return '<span style="color:tomato">root </span>' +
|
|
|
+ '<span style="color:sienna">' + self.cwd + ' </span>' +
|
|
|
'<span style="color:red">% </span>'
|
|
|
}
|
|
|
return '<span style="color:blueviolet">pgs </span>' +
|
|
|
@@ -40,14 +41,17 @@ function pgsh(ev) {
|
|
|
'etc': {},
|
|
|
'home': {
|
|
|
'pgs': {
|
|
|
- 'about.md':
|
|
|
- '# Parsley Gardens\n\nSite created by ** Weiyi Lou ** ' +
|
|
|
- new Date().getFullYear(),
|
|
|
'git.txt':
|
|
|
'Code Repository at <a target="_blank"' +
|
|
|
- 'href="https://code.parsleygardens.net/explore/projects">' +
|
|
|
+ 'href="https://code.parsleygardens.net/explore/repos">' +
|
|
|
'code.parsleygardens.net</a>',
|
|
|
- 'magic.txt': 'slightlymagic.com.au'
|
|
|
+ 'magic.txt':
|
|
|
+ 'Animation & Illustration at <a target="_blank"' +
|
|
|
+ 'href="http://slightlymagic.com.au">' +
|
|
|
+ 'slightlymagic.com.au</a>',
|
|
|
+ 'about.md':
|
|
|
+ '# Parsley Gardens\n' +
|
|
|
+ 'Made by Weiyi Lou ' + new Date().getFullYear(),
|
|
|
}
|
|
|
},
|
|
|
'mnt': {},
|
|
|
@@ -112,6 +116,7 @@ function pgsh(ev) {
|
|
|
}
|
|
|
this.cd = function(args) {
|
|
|
var arg = args.join(' ').trim()
|
|
|
+ arg = arg ? arg : getHome()
|
|
|
var path = resolveAbsPath(arg)
|
|
|
if (pathExists(path)) {
|
|
|
self.cwd = path
|
|
|
@@ -148,7 +153,7 @@ function pgsh(ev) {
|
|
|
} else if (command) {
|
|
|
show('No information for: ' + command)
|
|
|
} else {
|
|
|
- var commands = [];
|
|
|
+ var commands = []
|
|
|
for (var name in self.commands) {
|
|
|
commands.push(name)
|
|
|
}
|
|
|
@@ -162,11 +167,20 @@ function pgsh(ev) {
|
|
|
var path = resolveAbsPath(folder)
|
|
|
if (pathExists(path)) {
|
|
|
var contents = getContents(path)
|
|
|
- var output = ''
|
|
|
+ var items = []
|
|
|
for (var item in contents) {
|
|
|
- output += item + "\n"
|
|
|
+ items.push(item)
|
|
|
}
|
|
|
- show(output)
|
|
|
+ items.sort()
|
|
|
+ var dstat = 'drwxr-xr-x <span style="color:deepskyblue">'
|
|
|
+ var fstat = '-rw-r--r-- '
|
|
|
+ items.forEach(function(item, key, items) {
|
|
|
+ var prefix = (typeof contents[item] === 'string') ? fstat : dstat
|
|
|
+ var suffix = (typeof contents[item] === 'string') ? '' : '</span>'
|
|
|
+ items[key] = prefix + item + suffix
|
|
|
+ })
|
|
|
+ items.unshift([dstat + '..' + '</span>'])
|
|
|
+ show(items.join('\n'))
|
|
|
} else {
|
|
|
show("ls: " + args + ": no such directory")
|
|
|
}
|
|
|
@@ -215,8 +229,10 @@ function pgsh(ev) {
|
|
|
}
|
|
|
}
|
|
|
this.version = function(args) {
|
|
|
- show('Parsley Gardens Shell (pgsh) 1.0.0\nBuilt with ' +
|
|
|
- '<a target="_blank" href="http://riotjs.com/">Riot</a>')
|
|
|
+ show('Parsley Gardens Shell (pgsh) 1.1.0 Built with ' +
|
|
|
+ '<a target="_blank" href="http://riotjs.com">Riot</a> ' +
|
|
|
+ '<a target="_blank" href="https://skeleton-framework.github.io">Skeleton</a> ' +
|
|
|
+ '<a target="_blank" href="https://highlightjs.org">highlight.js</a>')
|
|
|
}
|
|
|
|
|
|
/**
|