-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor/more themes #2
base: main
Are you sure you want to change the base?
Conversation
- Refactor powerline colors: - cleaner gradient of color, - light/dark meta-sections alternance. - Adds a specific TAG color for `prompt_tag`. - Adds X11/Txt section. - Rename `powerline_full` in `powerline_plus`. - Add two sub-themes: - `power2lines`: display prompt after the colored line. - Adds meta-sections with gaps. - `powerpuff`: spread power2lines' sections on two rows and left/right aligned.
Screenshots are still missing an update. |
- refactor __powerline_section so as to allow easy chaining of segments having the same color. - adds support of: ram, disk, cmake, env_vars, modules, OS, error_meaning.
639f431
to
871c3d6
Compare
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.
Good start. I loaded each theme, and besides powerpuff, they all work well at first glance. I'll trust you on the color changes, though they need docs mentions that they changed. Unless we want to treat this as an entirely new theme, not one we are splitting off.
I don't have an opinion on that, so I'll let you decide. |
Or maybe we could keep the former color scheme as a |
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 don't have an opinion on that, so I'll let you decide.
I guess we don't have a good reason to not be explicit in documentation. I think what makes sense is that I release this theme as it is right now as v1.0.0, which supports Liquid Prompt 2.1 probably. Then you can target this PR to v1.1, and mark changes in the docs as such.
Or maybe we could keep the former color scheme as a
legacy.conf
preset?
Yes, I like that idea a lot.
Following my researches on colors, it may also be interesting to have a high contrast theme for powerline. Given that the background coloring is less prone to dark/light background incompatibilities, it seems feasible with the 256 colors space.
Sure, why not, presets are pretty easy to add and maintain.
In general this looks good, just a few issues.
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.
My only issue with these screenshots is that the cursor character looks different between them. Probably because it is blinking? A small nitpick to be sure.
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.
Yes. This comes from the automated screenshot scripts, so that the cursor is always displayed. Should I patch them in Gimp or is it OK as is?
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.
My need for perfection wants it patched out, but you can do whatever.
Bring back the former colors as a preset.
8a948f3
to
6072df5
Compare
OK! |
954bde3
to
d8944fc
Compare
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.
Looking pretty good. Everything works now. The docs are failing because they are trying to link to things in the Liquid Prompt docs that are not released to stable
yet.
Only issue is that the powerpuff theme is very slow on Bash. This isn't reflected:
$ time __lp_set_prompt
real 0m0.185s
user 0m0.156s
sys 0m0.030s
But from hitting enter to a new prompt appearing is almost exactly a second. If it's not something you are seeing, then I'll have to dig in.
I am starting to see that themes involving |
I should look into if we can improve the string multiplication/concatenation loop... I found this very helpful SO answer which includes a script to test possible implementations. There are two solutions that are faster than the loop we currently use, but they have issues that prevent us from using them (mainly that they use So that's out. But while our solution scales linearly with repetition count, I don't think it is causing our issues here. 100 count took 0.0004 seconds, and 200 count took 0.0008 seconds. I ran some tests to see if there was anything obviously slow, but nothing jumped out. I used this script to see that data: (
N=`date +%s%N`
PS4='+[$(((`date +%s%N`-$N)/1000000))ms][${BASH_SOURCE}:${LINENO}]: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -x
__lp_set_prompt
) 2>&1 | while read l; do
[[ ! ${l%%[*} =~ ^\+ ]] && echo $l && continue
i=`echo $l | sed 's#[^0-9]*\([0-9]\+\).*#\1#'`
echo $l | sed "s#${i}ms#${i}ms+$(($i-${p-0}))ms#"
p=$i
done Each line shows at least 2ms because the I think your hunch is right, but also I think it is a function of how many lines are executed. The default theme executed 526 lines, where your powerpuff theme executed 1833. I think that is why it is much slower. |
After a couple of tests, it seems much faster to avoid having a right-aligned segment. The SO answer you mentioned notes:
And If that's true, a fix would be to have a function that computes a string's "visible" length (not taking into account escaped characters), without using substring replacements. |
Indeed. And that would solve a lot of problems. See liquidprompt/liquidprompt#547 and liquidprompt/liquidprompt#599 for issues that would be helped for a solution here as well. Not to mention right prompt support has been a feature request in LP for a long time (liquidprompt/liquidprompt#154) This is very difficult though. I have done a lot of research into this before (though I can't find my comments on it right now). I think the only true and correct solution is to have the terminal emulator do the work. It would look like this:
This has many potential issues:
That said, this my implementation. Works on both Bash and Zsh. I would love a version that doesn't have the above issues. string_length() {
local string="$1"
local pos
printf "\0337"
printf "\033[6n"
IFS="" read -r -dR pos
printf "\0338"
pos="${pos#$'\E['}"
local old_row="${pos%;*}"
local old_column="${pos#*;}"
printf '%s' "$string"
printf "\033[6n"
IFS="" read -r -dR pos
printf "\0338"
pos="${pos#$'\E['}"
local new_row="${pos%;*}"
local new_column="${pos#*;}"
length=$(( (new_row - old_row) * COLUMNS + (new_column - old_column) ))
} |
refactor the powerline with a more consistent color scheme
rename powerline_full as powerline_plus
add two themes
adds support for features from LP 2.2