-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an optional 'plain' mode to the cwd segment. #156
Conversation
Rationale: A plain path like "~/projects/powerline-shell" can be easily copied&pasted, and also takes up less space in the prompt. The new command line parameter --cwd-mode controls the display of the cwd segment: --cwd-mode=fancy is the same as the current default --cwd-mode=plain is the new mode to display a plain path --cwd-mode=dironly is the same as the old parameter --cwd-only (which is still supported to keep backward compat)
Hey @paol -- sorry this didn't get looked at sooner. I like this change -- I would personally prefer the plain mode. There are some conflicts with your change right now. It would be great if you could resolve them. If I don't hear back from you I will try to get the conflicts resolved and merge this myself. |
Sure, I'll look at it this weekend |
Pull request should be upt to date now |
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(' %s%s ' % ('' if names[0] in '/~' else '/', '/'.join(names)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been thinking about this a little bit. The way you have it works great -- but it will have issues on Windows. What I am thinking we might want to do is just use the cwd
variable instead of joining the names
variable. This will not convert /home/user
to ~
though. I am ok with that as a first step though.
Ultimately, I think we need to do the following to properly solve that issue:
- Refactor the
get_short_path
into two separate functions. One that does string manipulation to replace/home/user
with~
and one that then breaks the string apart intonames
. - In plain mode, just use the first function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I am not asking you to do that refactor. If you just switch this code to use cwd
I would be cool to merge. I can tackle the refactor after merging.
Is this what you mean? |
Yeah exactly |
Just tested this locally -- this is great. I will merge and make those refactoring changes I talked about. Thanks a lot! |
Add an optional 'plain' mode to the cwd segment.
For reference, here is the refactoring I was talking about: dc7b8a3 |
Add an optional 'plain' mode to the cwd segment.
Add an optional 'plain' mode to the cwd segment.
Rationale: A plain path like "~/projects/powerline-shell" can be easily copied&pasted, and also takes up less space in the prompt.
The new command line parameter --cwd-mode controls the display of the cwd segment:
--cwd-mode=fancy is the same as the current default
--cwd-mode=plain is the new mode to display a plain path
--cwd-mode=dironly is the same as the old parameter --cwd-only (which is still supported to keep backward compat)