0

I have written my own zsh (actually, I'm using zsh with oh-my-zsh, if it's relevant to the subject) prompt, its code follows:

PROMPT="%{$fg[green]%n%}@%{%m%}:%{$fg[yellow]%~%} %{$fg[red]%#$reset_color%} "

Everything is fine except the only issue: when I use autocompletion (press Tab), prompt collapses to first few symbols.

Here's the screenshot, collapsed prompt is in the left Terminal window, and the normal prompt is in the right window.

https://i.stack.imgur.com/TcG7F.png

1 Answer 1

0

I'm not sure whether I got it exactly as you wanted but try this for a start:

local gr=${1:-'green'}
local bl=${2:-'blue'}
local re=${3:-'red'}
local wh=${4:-'white'}
local cy=${5:-'cyan'}
local ye=${6:-'yellow'}

export PROMPT="%F{$gr}%n%f@%m:%F{$ye}%~%f %F{$re}%#%f "

I'm not sure exactly what you did wrong, but it appears that those curly braces were messing with your prompt. By approach to prompt customization uses %F{$ID} where ID is one of the identifiers I defined for starting colouring and %f for stopping colouring. You can make text bold using %B (remove bold using %b).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.