Skip to content
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

Merged
merged 4 commits into from
Aug 26, 2015

Conversation

paol
Copy link

@paol paol commented Jul 12, 2014

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)

paol added 2 commits July 12, 2014 20:34
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)
vivekkrish added a commit to vivekkrish/powerline-shell that referenced this pull request Nov 16, 2014
@b-ryan
Copy link
Owner

b-ryan commented Aug 20, 2015

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.

@paol
Copy link
Author

paol commented Aug 21, 2015

Sure, I'll look at it this weekend

@paol
Copy link
Author

paol commented Aug 22, 2015

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)),
Copy link
Owner

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 into names.
  • In plain mode, just use the first function

Copy link
Owner

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.

@paol
Copy link
Author

paol commented Aug 24, 2015

Is this what you mean?

@b-ryan
Copy link
Owner

b-ryan commented Aug 24, 2015

Yeah exactly

@b-ryan
Copy link
Owner

b-ryan commented Aug 26, 2015

Just tested this locally -- this is great. I will merge and make those refactoring changes I talked about. Thanks a lot!

b-ryan added a commit that referenced this pull request Aug 26, 2015
Add an optional 'plain' mode to the cwd segment.
@b-ryan b-ryan merged commit 22cbcf0 into b-ryan:master Aug 26, 2015
@b-ryan
Copy link
Owner

b-ryan commented Aug 26, 2015

For reference, here is the refactoring I was talking about: dc7b8a3

@b-ryan b-ryan mentioned this pull request Dec 26, 2015
amtrivedi91 added a commit to amtrivedi91/powerline-shell that referenced this pull request Aug 31, 2016
Add an optional 'plain' mode to the cwd segment.
amtrivedi91 added a commit to amtrivedi91/powerline-shell that referenced this pull request Aug 31, 2016
Add an optional 'plain' mode to the cwd segment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants