"cwd": { "mode": "compact" }

This commit is contained in:
Marco Mariani 2017-09-29 10:40:51 +02:00
parent 3e025e2947
commit a7f17f2dc4
2 changed files with 7 additions and 2 deletions

View file

@ -217,8 +217,9 @@ for the `cwd` segment are set in `~/.powerline-shell.py` like:
The options for the `cwd` segment are:
- `mode`: If "plain" then simple text will be used to show the cwd. If
"dironly," only the current directory will be shown. Otherwise expands the
cwd into individual directories.
"dironly," only the current directory will be shown. If "compact",
simple text is used but is shortened according to "max_depth" and
"max_dir_size". Otherwise expands the cwd into individual directories.
- `max_depth`: Maximum number of directories to show in path
- `max_dir_size`: Maximum number of characters displayed for each directory in
the path

View file

@ -83,6 +83,10 @@ def add_cwd_segment(powerline):
# displayed, so chop everything else off
names = names[-1:]
if powerline.segment_conf("cwd", "mode") == "compact":
# Like plain but uses max_depth.
names = [os.path.join(*names)]
for i, name in enumerate(names):
is_last_dir = (i == len(names) - 1)
fg, bg = get_fg_bg(powerline, name, is_last_dir)