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

Move to a function override approach #226

Closed
wants to merge 2 commits into from
Closed

Conversation

frm
Copy link
Member

@frm frm commented Sep 21, 2018

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:

screen shot 2018-09-21 at 14 04 41

Before reload I simply uncommented the override function. Dotfiles:

geometry_prompt_path_render_override() {
  echo " \n$geometry_colorized_prompt_dir $geometry_colorized_prompt_symbol"
}

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=""
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

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.
@frm frm requested a review from jedahan September 21, 2018 13:07
@frm
Copy link
Member Author

frm commented Sep 21, 2018

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:

screen shot 2018-09-21 at 14 39 26

Comparison with default geometry:

screen shot 2018-09-21 at 14 42 32

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

@jedahan
Copy link
Member

jedahan commented Oct 5, 2018

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.

@frm
Copy link
Member Author

frm commented Oct 5, 2018

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.

@jedahan
Copy link
Member

jedahan commented Oct 5, 2018

@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

@jedahan
Copy link
Member

jedahan commented Jan 2, 2019

@justmendes so I pushed a change to my mnml branch, that documents and exposes geometry_git_{branch,conflicts,rebase,remote,stashes,status,symbol}, and creates geometry::git_wrapper which is just the joiner for the right hand side. So this should allow some easy customization of either side prompt, while removing the three weird GEOMETRY_GIT_SHOW_{TIME,CONFLICTS,STASHES} variables. Lemme know if it breaks things!

@frm
Copy link
Member Author

frm commented Jan 15, 2019

@jedahan I'd prefer to release a version for users to try out and then dedicate myself to trying this 😄 great work

@jedahan jedahan added this to the 2.0.0 milestone Jan 15, 2019
@jedahan
Copy link
Member

jedahan commented Aug 21, 2019

superseded by mnml branch

@jedahan jedahan closed this Aug 21, 2019
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.

None yet

2 participants