-
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
Initial plugin architecture set up #43
Conversation
PROMPT_GEOMETRY_SHOW_RPROMPT=${PROMPT_GEOMETRY_SHOW_RPROMPT:-true} | ||
PROMPT_GEOMETRY_RPROMPT_ASYNC=${PROMPT_GEOMETRY_RPROMPT_ASYNC:-true} | ||
PROMPT_GEOMETRY_ENABLE_PLUGINS=${PROMPT_GEOMETRY_ENABLE_PLUGINS:-true} |
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 configuration is probably unnecessary, having PROMPT_GEOMETRY_SHOW_RPROMPT
.
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.
What is the first variable supposed to do?
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.
PROMPT_GEOMETRY_SHOW_RPROMPT
is used to activate or deactive the rprompt, meanwhile PROMPT_GEOMETRY_ENABLE_PLUGINS
activates the plugins (internal and custom). The issue is -currently- the rprompt only shows plugins.
@@ -0,0 +1,33 @@ | |||
# Misc configurations | |||
GEOMETRY_ASYNC_PROMPT_TMP_FILENAME=${GEOMETRY_ASYNC_PROMPT_TMP_FILENAME:-/tmp/geometry-prompt-git-info-} |
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.
Change default tmp file name.
|
||
TRAPUSR1() { | ||
# read from temp file | ||
RPROMPT="$(<${GEOMETRY_ASYNC_PROMPT_TMP_FILENAME}$$)" |
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.
Remove tmp file.
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.
Do you have any ideas regarding an alternative for tmp files? I can see piping doing the job but is it that much necessary?
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.
Well, there is zsh-async.
geometry_plugin_setup() { | ||
for plugin in $GEOMETRY_PROMPT_DEFAULT_PROMPTS; do | ||
source "$GEOMETRY_ROOT/plugins/$plugin.zsh" | ||
geometry_plugin_register $plugin |
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.
Probably better to leave plugin to self-register
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'd prefer having a plugin self-register.
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.
👍
# Register a plugin | ||
geometry_plugin_register() { | ||
local plugin=$1 | ||
if [[ $plugin == "" ]]; then |
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.
Use argument count
local seconds=$(( total_seconds % 60 )) | ||
|
||
if $PROMPT_GEOMETRY_GIT_TIME_SHORT_FORMAT; then | ||
if (( days > 0 )); then |
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.
Move each if branch into it's own functions.
@@ -0,0 +1,5 @@ | |||
# Geometry plugins |
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.
- Add example plugin structure
- Add
setup
return values definition - Add
render
return values definition
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 have a README almost ready, was working for the current version. Just need to adapt it. Can you change the base branch to something like 2.0
instead of master
? That way I can contribute as well.
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.
Alright, I'm gonna create v2
branch and target this PR to it.
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.
Done. It was created from master
. I guess we can already merge this feature branch and continue working on v2
.
source "$GEOMETRY_ROOT/lib/plugin.zsh" | ||
source "$GEOMETRY_ROOT/lib/time.zsh" | ||
source "$GEOMETRY_ROOT/lib/color.zsh" | ||
source "$GEOMETRY_ROOT/lib/grep.zsh" |
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.
Not sure about this. Should we have a compilation script to bundle everything into geometry?
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'd rather have that. And have it make sure we only source it once.
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.
Do you mean to use source
instead of a makefile-like approach?
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.
Oh, I thought you meant sourcing them all. A Makefile-like approach would have to be on install, wouldn't it?
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.
On a build step. Maybe it's too cumbersome as of now. I'm gonna leave it as it is, sourcing them as currently implemented.
GEOMETRY_ASYNC_PROMPT_TMP_FILENAME=${GEOMETRY_ASYNC_PROMPT_TMP_FILENAME:-/tmp/geometry-prompt-git-info-} | ||
|
||
GEOMETRY_ASYNC_PROMPT_PROC=0 | ||
prompt_geometry_setup_async_prompt() { |
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.
Rename to geometry_async_setup
?
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.
👍 agreed
@@ -0,0 +1,20 @@ | |||
# Define how to colorize before the variables | |||
prompt_geometry_colorize() { |
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.
Rename to geometry_color_colorize
?
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.
Not sure. color_colorize
doesn't read well to me. Since we keep using this function throughout the prompt why not a shorthand name? Even if it's -g-color
, just to save characters.
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.
geometry_color_colorize
would follow the format geometry_<lib>_<function>
. I could also add, as an alias, a -g-color
function.
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.
Second option seems nice.
Really liking the way this is going. Great job! I'd recommend, like I said in another comment, putting the PR on a different branch. That way I and someone who would like to help can jump in easily. A lot of comments you had there could be in a TODO list, together with the list already on the PR description. I'd like to have some issues and improvements flagged for people looking for their first PR. Props for flagging some issues, really helps with that. |
local days=$(( total_seconds / 60 / 60 / 24 )) | ||
local hours=$(( total_seconds / 60 / 60 % 24 )) | ||
local minutes=$(( total_seconds / 60 % 60 )) | ||
local seconds=$(( total_seconds % 60 )) | ||
|
||
if $PROMPT_GEOMETRY_GIT_TIME_SHORT_FORMAT; then | ||
# It looks redundant but it seems it's not | ||
if [[ $long_format == true ]]; then |
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.
Do we need == true
?
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.
Not sure tbh. I tried [[ $long_format ]]
and it messed up. Gonna take a look later today to see what was going on.
Gonna merge to All development regarding plugins should be done in a feature branch branched off |
Moved most helper functions (
prompt_geometry_colorize
,prompt_geometry_hash_color
,prompt_geometry_seconds_to_human_time
,prompt_geometry_setup_async_prompt
) tolib/
directory.Created
plugins/
directory with default plugins: git, exec_timeMove most variables/flags to it's plugin file
It does support custom prompts! Example.
It does works :D
TODO
README.md
Fixes #42