Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implemented support for command-line options.

--shell [zsh|bash]
	which shell to emit color escapes for; defaults to zsh
--cwd-only
	use only the current working directory in the prompt; defaults to false
--mode [patched|compatible]
	which font mode to expect; defaults to patched

Any further arguments are presumed to be $? aka the error returned by the
previous command.
  • Loading branch information...
commit f9417917aa53cc37675c62791da2937c43fdc7d4 1 parent 3517d4b
@ceejbot authored
Showing with 31 additions and 3 deletions.
  1. +31 −3 bin/powerline.js
View
34 bin/powerline.js
@@ -313,14 +313,42 @@ Segment.prototype.draw = function(nextSegment)
if (require.main === module)
{
- var p = new Powerline('patched', 'zsh');
+ var opts = process.argv.slice(2);
+ var cwdOnly = false;
+ var shell = 'zsh';
+ var mode = 'patched';
+ var prevError = false;
+
+ while (opts.length)
+ {
+ var opt = opts.shift();
+ switch (opt)
+ {
+ case '--cwd-only':
+ cwdOnly = true;
+ break;
+
+ case '--shell':
+ shell = opts.shift();
+ break;
+
+ case '--mode':
+ mode = opts.shift();
+ break;
+
+ default:
+ prevError = (opt !== '0');
+ }
+ }
+
+ var p = new Powerline(mode, shell);
var cwd = process.cwd();
p.addVirtualEnvSegment(cwd);
- p.addCWDSegment(cwd, 5, false);
+ p.addCWDSegment(cwd, 5, cwdOnly);
p.addRepoSegment(cwd, function()
{
- p.addRootIndicator();
+ p.addRootIndicator(prevError);
process.stdout.write(p.draw());
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.