Pure: Higlight slashes in the path to visualize the path components

Created on 23 Aug 2018  路  6Comments  路  Source: sindresorhus/pure

Issuehunt badges

This is a feature request.

Please, compare these two screenshots:

![scr1]
![scr2]

Personally, I find it useful, and maybe you will like it too.
The method I use is buggy, as it can't handle % anywhere in the path:

diff --git a/pure.zsh b/pure.zsh
index e3813b7..fc96474 100644
--- a/pure.zsh
+++ b/pure.zsh
@@ -113,9 +113,8 @@ prompt_pure_preprompt_render() {
# Initialize the preprompt array.
  local -a preprompt_parts
    -
# Set the path.
-       preprompt_parts+=('%F{blue}%~%f')
+       preprompt_parts+=('%F{blue}${${(%):-%~}//\//%B/%b}%f')
# Add git branch and dirty status info.
  typeset -gA prompt_pure_vcs_info

There is a $40.00 open bounty on this issue. Add more on Issuehunt.

Funded on Issuehunt enhancement help wanted

Most helpful comment

I would rather do the inverse and slightly dim the path separators.

All 6 comments

I would rather do the inverse and slightly dim the path separators.

So something like preprompt_parts+=('%F{blue}${${(%):-%~}//\//%F{24\}/%f%F{blue\}}%f')? It could be hard to come up with a good dimmed color.

It could be hard to come up with a good dimmed color.

Agree, I played with the background color, but nothing worked for me as good as a simple bold.

@issuehunt has funded $40.00 to this issue.


I've grown into the realization that having the last path component highlighted is more useful for me.
scr

I do it this way:

function cwd() { print ${(D)PWD} }
function path_head() { print ${${"$(cwd)"%/*}} }
function esc_path_tail() { print ${${"$(cwd)"#"$(path_head)"}//\%/%%} } # escape '%'
function esc_path_head() { print ${$(path_head)//\%/%%} } # escape '%'
# ...
preprompt_parts+=('%F{${prompt_pure_colors[path]}}$(esc_path_head)%f%F{12}$(esc_path_tail)%f')

Feel free to reuse this snippet if you want to.

Was this page helpful?
0 / 5 - 0 ratings