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

Allow extra data from a _pure_custom_postpath function #563

Closed
wants to merge 1 commit into from

Conversation

marcusirgens
Copy link

When using aws-vault, it's sometimes very nice to know which profile is active. I've previously used other (slower) prompts, but I really missed having this data in pure.

However, I realise that adding support for a ton of third party stuff is not the goal of this project, so I was wondering if a simple function "plugin" hook could be added? This pull request very simply checks for a function named _pure_custom_postpath, and if it exists, it's invoked and the output is appended after the path part in the prompt.

As there's a note in the readme saying ...

Makes an excellent starting point for your own custom prompt.

... I assume that the threshold for adding stuff to pure itself is quite high, so if this is something you explicitly don't want to add I fully understand that. I'm also open to different implementations or ideas for how to potentially make pure "pluggable".

@marcusirgens
Copy link
Author

I just now realised that #460 deals with this stuff.

@mafredri
Copy link
Collaborator

@marcusirgens indeed it does, and that would be the ideal solution. But nobody is working on it at the moment AFAIK.

Now, if you don't mind making your own changes / forking, it's a simple one line change 😄:

diff --git pure.zsh pure.zsh
index 2cbd7d0..d8326ae 100644
--- pure.zsh
+++ pure.zsh
@@ -135,7 +135,7 @@ prompt_pure_preprompt_render() {
 	[[ -n $prompt_pure_state[username] ]] && preprompt_parts+=($prompt_pure_state[username])
 
 	# Set the path.
-	preprompt_parts+=('%F{${prompt_pure_colors[path]}}%~%f')
+	preprompt_parts+=('%F{${prompt_pure_colors[path]}}%1~%f')
 
 	# Git branch and dirty status info.
 	typeset -gA prompt_pure_vcs_info

@marcusirgens
Copy link
Author

marcusirgens commented Sep 10, 2020

diff --git pure.zsh pure.zsh> 
index 2cbd7d0..d8326ae 100644> 
--- pure.zsh> 
+++ pure.zsh> 
@@ -135,7 +135,7 @@ prompt_pure_preprompt_render() {> 
 	[[ -n $prompt_pure_state[username] ]] && preprompt_parts+=($prompt_pure_state[username])> 

 	# Set the path.
-	preprompt_parts+=('%F{${prompt_pure_colors[path]}}%~%f')
+	preprompt_parts+=('%F{${prompt_pure_colors[path]}}%1~%f')
 
 	# Git branch and dirty status info.
 	typeset -gA prompt_pure_vcs_info

I'm afraid I don't fully understand what this change does?

@mafredri
Copy link
Collaborator

Sorry for the confusion @marcusirgens, I thought I was replying to #562 (case of too many tabs 😅)...


Back to this PR, as you noticed, #460 is how we'd ideally like to solve this issue as it's more flexible. I'm not entirely opposed to having a possibility for prefix/postfix in Pure, but I'm sure we'd still see requests for changing order or removing some part entirely. A solution which is easy to use and tries to prevent user error (e.g. hide array manipulations) would be preferable here.

Base automatically changed from master to main January 24, 2021 06:08
@sindresorhus
Copy link
Owner

// @marcusirgens

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.

3 participants