-
Notifications
You must be signed in to change notification settings - Fork 94
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
Move to a function override approach #226
Conversation
Currently we are using variables to override values. Variables aren't very flexible. This is making the codebase hard to read to read and maintain. This is a proposal commit to move to a function override based approach. This approach would allow users to better configure their prompts and plugins without having to fork and change the source code.
Extended the proof of concept to git to display how easy it is to move things around differently from default geometry. With git and path overrides: Comparison with default geometry: Personal config that overrides geometry: geometry_prompt_path_render_override() {
echo " \n$var_geometry_colorized_prompt_dir $var_geometry_colorized_prompt_symbol"
}
geometry_prompt_git_render_override() {
local git_prompt="$(prompt_geometry_git_branch) $(prompt_geometry_git_status) $(prompt_geometry_git_symbol)${var_geometry_git_conflicts}"
echo -e $git_prompt | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'
}
GEOMETRY_COLOR_GIT_DIRTY=9
GEOMETRY_COLOR_GIT_BRANCH=6
GEOMETRY_COLOR_EXIT_VALUE=9
GEOMETRY_COLOR_DIR=242
GEOMETRY_COLOR_PROMPT=2
GEOMETRY_SYMBOL_EXIT_VALUE="⇝"
GEOMETRY_SYMBOL_PROMPT="⇝"
GEOMETRY_PROMPT_PATH="%2~"
GEOMETRY_SYMBOL_GIT_DIRTY="⑇"
GEOMETRY_SYMBOL_GIT_CLEAN="⑉"
GEOMETRY_SYMBOL_GIT_CONFLICTS_SOLVED="⑉"
GEOMETRY_SYMBOL_GIT_CONFLICTS_UNSOLVED="⑆"
PROMPT_GEOMETRY_GIT_SHOW_STASHES=false
GEOMETRY_PROMPT_PLUGINS_PRIMARY=(path)
GEOMETRY_PROMPT_PLUGINS_SECONDARY=(git)
PROMPT_GEOMETRY_GIT_CONFLICTS=true
GEOMETRY_ENV="development"
source $HOME/Developer/geometry/$GEOMETRY_ENV/geometry.zsh |
So I like the direction of this, but we are now adding even more names for people to know about/find/remember, and whether they are a variable or function. I'd love for us to extend this idea even further to something more like MNML style. |
I like it. I want to achieve something like that and reduce the amount of variables and functions we need to know. Increase maintainability and extensibility. Right now there's an option for everything and it's hard to keep track of it all. I didn't want to continue to refactor if this wasn't seen as a viable option 😄 I'll update soon. |
@fribmendes I started a test refactor with mnml as a base - https://github.com/geometry-zsh/geometry/tree/mnml take a look at that it seems promising |
@justmendes so I pushed a change to my mnml branch, that documents and exposes |
@jedahan I'd prefer to release a version for users to try out and then dedicate myself to trying this 😄 great work |
superseded by mnml branch |
Currently we are using variables to override values.
Variables aren't very flexible. This is making the codebase hard to read
to read and maintain.
This is a proposal commit to move to a function override based approach. If accepted, I can change other plugins to do the same.
This approach would allow users to better configure their prompts and
plugins without having to fork and change the source code. It would also remove the need for variables that represent personal taste, like prompt prefixes and suffixes.
Example:
Before
reload
I simply uncommented the override function. Dotfiles: