-
Notifications
You must be signed in to change notification settings - Fork 53
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
Multiline prompt #25
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,25 @@ function $_hydro_git --on-variable $_hydro_git | |
end | ||
|
||
function _hydro_pwd --on-variable PWD | ||
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 -- "(\.?[^/]{1})[^/]*/" \$1/ | | ||
string replace -- : "$root" | | ||
string replace --regex -- '([^/]+)$' "\x1b[1m\$1\x1b[22m" | | ||
string replace --regex --all -- '(?!^/$)/' "\x1b[2m/\x1b[22m" | ||
) | ||
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 | ||
test "$root" != "$_hydro_git_root" && | ||
set --global _hydro_git_root $root && set $_hydro_git | ||
end | ||
|
@@ -38,11 +47,11 @@ end | |
function _hydro_prompt --on-event fish_prompt | ||
set --local last_status $pipestatus | ||
set --query _hydro_pwd || _hydro_pwd | ||
set --global _hydro_prompt "$_hydro_color_prompt$hydro_symbol_prompt" | ||
set --global _hydro_prompt "$_hydro_newline$_hydro_color_prompt$hydro_symbol_prompt" | ||
|
||
for code in $last_status | ||
if test $code -ne 0 | ||
set _hydro_prompt "$_hydro_color_error"[(string join "\x1b[2mǀ\x1b[22m" $last_status)] | ||
set _hydro_prompt "$_hydro_newline$_hydro_color_error"[(string join "\x1b[2mǀ\x1b[22m" $last_status)] | ||
break | ||
end | ||
end | ||
|
@@ -105,8 +114,17 @@ for color in hydro_color_{pwd,git,error,prompt,duration} | |
end && $color | ||
end | ||
|
||
function hydro_multiline --on-variable hydro_multiline | ||
if test "$hydro_multiline" = true | ||
set --global _hydro_newline "\n" | ||
else | ||
set --global _hydro_newline "" | ||
end | ||
end && hydro_multiline | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mischievous, but I'll allow it, lol. 👍 |
||
|
||
set --query hydro_color_error || set --global hydro_color_error $fish_color_error | ||
set --query hydro_symbol_prompt || set --global hydro_symbol_prompt ❱ | ||
set --query hydro_symbol_git_dirty || set --global hydro_symbol_git_dirty • | ||
set --query hydro_symbol_git_ahead || set --global hydro_symbol_git_ahead ↑ | ||
set --query hydro_symbol_git_behind || set --global hydro_symbol_git_behind ↓ | ||
set --query hydro_multiline || set --global hydro_multiline false |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.