diff --git a/README.md b/README.md index ec2d732d..dd8a44cd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/powerline_shell_base.py b/powerline_shell_base.py index e2775fe1..7753dead 100755 --- a/powerline_shell_base.py +++ b/powerline_shell_base.py @@ -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', diff --git a/segments/cwd.py b/segments/cwd.py index 70724b00..d42124f7 100644 --- a/segments/cwd.py +++ b/segments/cwd.py @@ -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()