zsh-users
 help / color / mirror / code / Atom feed
* How to change path in prompt to /d/i/r format?
@ 2014-12-18 14:50 Shiyao Ma
  2014-12-18 15:04 ` Mikael Magnusson
  0 siblings, 1 reply; 2+ messages in thread
From: Shiyao Ma @ 2014-12-18 14:50 UTC (permalink / raw)
  To: zsh-users

Hi.

My current prompt setup is:

####################################################################################################
local max_path_chars=45
local user_char='❯'
local root_char='❯❯❯'
local success_color='%F{071}'
local failure_color='%F{124}'
local vcs_info_color='%F{242}'

# Set vcs_info parameters.
zstyle ':vcs_info:*' enable git hg svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '!'
zstyle ':vcs_info:*' stagedstr '+'
zstyle ':vcs_info:*' actionformats "%S" "%r/%s/%b %u%c (%a)"
zstyle ':vcs_info:*' formats "%S" "%r/%s/%b %u%c"
zstyle ':vcs_info:*' nvcsformats "%d" ""

# Define prompts.
PROMPT="%(?.${success_color}.${failure_color})${SSH_TTY:+[%n@%m]}%B%${max_path_chars}<...<"'${${(%)vcs_info_msg_0_}/#$HOME/~}'"%<<%(!.${root_char}.${user_char})%b%f "
RPROMPT="${vcs_info_color}"'${vcs_info_msg_1_}'"%f"

####################################################################################################

For long pathes, it will be abruptly cut into the format, e.g., "...lfred 2/Alfred.alfredpreferences/resources❯"

whereas the realpath is: "/Users/John/Library/Application Support/Alfred 2/Alfred.alfredpreferences/resources"

I know ZSH is powerful, so here goes my question.

How to modify the prompt, so the section of address longer than the ${max_path_chars} will be reduced to,
/U/J/L/A/A/ in this example.

So the final form is
/U/J/L/A/A/Alfred.alfredpreferences/resources


If you have better path format in mind, I am all hears.

Thanks in advance.

Regards.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-18 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 14:50 How to change path in prompt to /d/i/r format? Shiyao Ma
2014-12-18 15:04 ` Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).