Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a --depth command-line option to control how many directory segme…

…nts are shown.

And improve the truncation a bit.
  • Loading branch information...
commit 4cd26b89da34e8dc2118e2fbd06a20ef909ec615 1 parent f941791
@ceejbot authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 bin/powerline.js
View
14 bin/powerline.js
@@ -111,11 +111,15 @@ Powerline.prototype.draw = function(code)
cwd = cwd.replace(home, '~');
if (cwd[0] === '/')
- cwd.shift();
+ cwd = cwd.substring(1, cwd.length);
var names = cwd.split('/');
if (names.length > maxdepth)
- names.splice(2, names.length - maxdepth, '\u2026');
+ {
+ var diff = names.length - maxdepth;
+ var start = maxdepth > 4 ? 2 : 1;
+ names.splice(start, diff + 1, '\u2026');
+ }
if (!cwdOnly)
{
@@ -318,6 +322,7 @@ if (require.main === module)
var shell = 'zsh';
var mode = 'patched';
var prevError = false;
+ var depth = 5;
while (opts.length)
{
@@ -336,6 +341,9 @@ if (require.main === module)
mode = opts.shift();
break;
+ case '--depth':
+ depth = parseInt(opts.shift(), 10);
+
default:
prevError = (opt !== '0');
}
@@ -345,7 +353,7 @@ if (require.main === module)
var cwd = process.cwd();
p.addVirtualEnvSegment(cwd);
- p.addCWDSegment(cwd, 5, cwdOnly);
+ p.addCWDSegment(cwd, depth, cwdOnly);
p.addRepoSegment(cwd, function()
{
p.addRootIndicator(prevError);
Please sign in to comment.
Something went wrong with that request. Please try again.