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

Multiline prompt #25

Merged
merged 3 commits into from
Jan 19, 2022
Merged

Multiline prompt #25

merged 3 commits into from
Jan 19, 2022

Conversation

mattmc3
Copy link
Collaborator

@mattmc3 mattmc3 commented Nov 24, 2021

This is an alternative implementation of #21 that builds on the idea with a couple extras:

  • Multiline prompts display the full path because there's room
  • Single line prompts allow customization of path length via the fish_prompt_pwd_dir_length variable (similar to the prompt_pwd implementation)

@jorgebucaran
Copy link
Owner

Thank you, @mattmc3! Can you upload a screenshot, video, or GIF to demonstrate this new functionality?

@mattmc3
Copy link
Collaborator Author

mattmc3 commented Dec 3, 2021

@jorgebucaran - Is this the kind of thing you were looking for?

Screen Shot 2021-12-03 at 6 46 57 PM

@mattmc3
Copy link
Collaborator Author

mattmc3 commented Jan 19, 2022

Any word on if this is able to merge or if there's anything more I need to do?

@jorgebucaran
Copy link
Owner

Thank you, @mattmc3. I think this is probably fine. Do you have any info on how this might affect performance?

Comment on lines +10 to +28
set --query fish_prompt_pwd_dir_length || set --local fish_prompt_pwd_dir_length 1
if test "$fish_prompt_pwd_dir_length" -le 0 || test "$hydro_multiline" = true
set --global _hydro_pwd (
string replace --ignore-case -- ~ \~ $PWD |
string replace --regex -- '([^/]+)$' "\x1b[1m\$1\x1b[22m" |
string replace --regex --all -- '(?!^/$)/' "\x1b[2m/\x1b[22m"
)
else
set --local root (command git rev-parse --show-toplevel 2>/dev/null |
string replace --all --regex -- "^.*/" "")
set --global _hydro_pwd (
string replace --ignore-case -- ~ \~ $PWD |
string replace -- "/$root/" /:/ |
string replace --regex --all -- "(\.?[^/]{"$fish_prompt_pwd_dir_length"})[^/]*/" \$1/ |
string replace -- : "$root" |
string replace --regex -- '([^/]+)$' "\x1b[1m\$1\x1b[22m" |
string replace --regex --all -- '(?!^/$)/' "\x1b[2m/\x1b[22m"
)
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place that maybe feels a little kludgy and duplicative to me, but I don't think it will have any impact on performance or usability.

@mattmc3
Copy link
Collaborator Author

mattmc3 commented Jan 19, 2022

I don't have any reason to think that these changes would impact performance in any meaningful way, and have used this fork as my daily driver prompt for a couple months now. There's effectively one more --on-variable hook and one additional if statement. Did you have a benchmark you'd like me to run or a particular place in the code that needs tuned?

else
set --global _hydro_newline ""
end
end && hydro_multiline
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mischievous, but I'll allow it, lol. 👍

@jorgebucaran jorgebucaran merged commit 74cf14b into jorgebucaran:main Jan 19, 2022
@mattmc3 mattmc3 deleted the multiline-prompt branch April 5, 2022 01:13
@jorgebucaran
Copy link
Owner

I've been using the multiline prompt and would prefer if it truncated the prompt, instead of displaying the full path. If we want to display the full path instead, here's a way:

set fish_prompt_pwd_dir_length -1

Hopefully, we can agree that this isn't so bad? 🙏

cc @mattmc3

@mattmc3
Copy link
Collaborator Author

mattmc3 commented May 31, 2022

That works! As long as there's a way to show the full path, the default value of fish_prompt_pwd_dir_length can be whatever your preference it @jorgebucaran.

@jorgebucaran jorgebucaran added the enhancement New feature or request label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants