agnoster / agnoster-zsh-theme

A ZSH theme designed to disclose information contextually, with a powerline aesthetic
4.02k stars 591 forks source link

Add the prompt view customization ability #91

Closed apodkutin closed 6 years ago

apodkutin commented 6 years ago

By default prompt has these segments: prompt_status, prompt_context, prompt_virtualenv, prompt_dir, prompt_git, prompt_end in that particular order.

If you want to add, change the order or remove some segments of the prompt, you can use array environment variable named AGNOSTER_PROMPT_SEGMENTS.

Examples:

A small demo of the dummy custom prompt segment, which has been created with help of the built-in prompt_segment() function from Agnoster theme:

# prompt_segment() - Takes two arguments, background and foreground.
# Both can be omitted, rendering default background/foreground.

customize_agnoster() {
  prompt_segment 'red' '' ' ⚙ ⚡⚡⚡ ⚙  '
}

Customization demo

apjanke commented 6 years ago

I like it! This looks like a good approach to making the whole prompt more customizable.

One niggle: I would personally call the variable AGNOSTER_PROMPT_SEGMENTS instead of AGNOSTER_PROMPT, since a <foo>_PROMPT variable is usually a single formatted non-array string variable that defines a prompt, instead of an array.

Really good PR write-up too; kudos to you.

agnoster commented 6 years ago

Yes, this looks great! I agree with @apjanke re: naming, (AGNOSTER_PROMPT_SEGMENTS would be a better name for the config variable), with that change I'd be happy to merge.

Also +1 to the write-up.

apodkutin commented 6 years ago

@apjanke, @agnoster Thank you guys! I will do it today.

apodkutin commented 6 years ago

Thank you @MichaelAquilina ! @apjanke, @agnoster PR has been updated.

There is also PR in oh-my-zsh repository, if you are interested in https://github.com/robbyrussell/oh-my-zsh/pull/7355

agnoster commented 6 years ago

Small note: it looks like in the GIF demo there's something wrong with the color of the triangular segments - the very first one should be blue to match the directory, but appears black in the capture. Which terminal / color scheme are you using? I don't think it's related to the change here, but it'd be nice if the GIF demonstrating the feature had the right colors. For an example of what the prompt ought to look like, see:

Reference Screenshot

apodkutin commented 6 years ago

Good catch @agnoster, I'm using iterm2/Solarized dark. I will fix it and will make a new recording of the demo.

And about your proposal regarding status>context>virtualenv>dir>git> config, I will try to implement it in the next PR.

apodkutin commented 6 years ago

@agnoster, GIF demo recording has been updated.

agnoster commented 6 years ago

Thanks again, this is wonderful!