Skip to content

Commit

Permalink
Merge pull request b-ryan#156 from paol/cwd_plain
Browse files Browse the repository at this point in the history
Add an optional 'plain' mode to the cwd segment.
  • Loading branch information
amtrivedi91 committed Aug 30, 2016
2 parents b37ed1f + 491ce68 commit be6a0a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ setting your $TERM to `xterm-256color`, because that works for me.
There are a few optional arguments which can be seen by running `powerline-shell.py --help`.

```
--cwd-only Only show the current directory
--cwd-mode {fancy,plain,dironly}
How to display the current directory
--cwd-max-depth CWD_MAX_DEPTH
Maximum number of directories to show in path
--colorize-hostname Colorize the hostname based on a hash of itself.
Expand Down
5 changes: 4 additions & 1 deletion powerline_shell_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ def get_valid_cwd():

if __name__ == "__main__":
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('--cwd-mode', action='store',
help='How to display the current directory', default='fancy',
choices=['fancy', 'plain', 'dironly'])
arg_parser.add_argument('--cwd-only', action='store_true',
help='Only show the current directory')
help='Deprecated. Use --cwd-mode=dironly')
arg_parser.add_argument('--cwd-max-depth', action='store', type=int,
default=5, help='Maximum number of directories to show in path')
arg_parser.add_argument('--colorize-hostname', action='store_true',
Expand Down
25 changes: 14 additions & 11 deletions segments/cwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ def add_cwd_segment():
if len(names) > max_depth:
names = names[:2] + [u'\u2026'] + names[2 - max_depth:]

if not powerline.args.cwd_only:
for n in names[:-1]:
if n == '~' and Color.HOME_SPECIAL_DISPLAY:
powerline.append(' %s ' % n, Color.HOME_FG, Color.HOME_BG)
else:
powerline.append(' %s ' % n, Color.PATH_FG, Color.PATH_BG,
powerline.separator_thin, Color.SEPARATOR_FG)

if names[-1] == '~' and Color.HOME_SPECIAL_DISPLAY:
powerline.append(' %s ' % names[-1], Color.HOME_FG, Color.HOME_BG)
if powerline.args.cwd_mode=='plain':
powerline.append(cwd, Color.CWD_FG, Color.PATH_BG)
else:
powerline.append(' %s ' % names[-1], Color.CWD_FG, Color.PATH_BG)
if not (powerline.args.cwd_mode=='dironly' or powerline.args.cwd_only):
for n in names[:-1]:
if n == '~' and Color.HOME_SPECIAL_DISPLAY:
powerline.append(' %s ' % n, Color.HOME_FG, Color.HOME_BG)
else:
powerline.append(' %s ' % n, Color.PATH_FG, Color.PATH_BG,
powerline.separator_thin, Color.SEPARATOR_FG)

if names[-1] == '~' and Color.HOME_SPECIAL_DISPLAY:
powerline.append(' %s ' % names[-1], Color.HOME_FG, Color.HOME_BG)
else:
powerline.append(' %s ' % names[-1], Color.CWD_FG, Color.PATH_BG)

add_cwd_segment()

0 comments on commit be6a0a5

Please sign in to comment.