You are not logged in.

#1 2012-02-14 21:00:38

Bladtman242
Member
Registered: 2012-02-14
Posts: 127

[SOLVED] zsh prompt colors misaligns the prompt

Im using urxvt.
For some reason, using colors in zsh somewhat screws up my prompt.
In effect, the cursor ends up inside the left hand prompt (see screenhot).
Also; the right hand prompt gets indented about 5 spaces to much from the right.
messed up prompt

This is my .zshrc:

#open tmux on startup
#[[ $TERM != "screen" ]] && tmux && exit
autoload -Uz compinit
compinit

#zstyle ':completion*' menu select
#setopt completealiases

#autoload -U promptinit
#promptinit
autoload -U colors && colors
function precmd () {
	local battp=$(ibam --percentbattery | grep % | awk '{print $3}')
	RPROMPT="[%~] [$battp]"
}
PROMPT="[%n@%m:]$ "

#keybindings
bindkey "^[[7~" 	beginning-of-line # Home
bindkey "^[[8~" 	end-of-line # End
bindkey "^[[5~" 	history-beginning-search-backward # PageUp
bindkey "^[[6~" 	history-beginning-search-forward # PageDown
bindkey "^[[2~" 	quoted-insert # Ins
bindkey "^[[3~" 	delete-char # Del
bindkey "^[[1;5C" 	forward-word
bindkey "\eOc" 		emacs-forward-word
bindkey "^[[1;5D" 	backward-word
bindkey "\eOd" 		emacs-backward-word
bindkey "^[[Z" 		reverse-menu-complete # Shift+Tab

HISTFILE=~/.histfile
HISTSIZE=65536
SAVEHIST=65000

#aliases
alias ls='ls --color=auto'
alias df='df -hT'
alias cl='clear'
alias ll='ls -l'
alias la='ls -A'
alias free='free -m'
alias wcu='wicd-curses'

# The following lines were added by compinstall

zstyle ':completion:*' completer _complete _ignored
zstyle ':completion:*' file-sort name
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[. -]=** r:|=**'
zstyle ':completion:*' menu select=0
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle :compinstall filename '/home/bladt/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=15000
bindkey -e
# End of lines configured by zsh-newuser-install

It seems to have been messed up a little by compinit, lets pretend that didn't happen big_smile

(note that "autoload -U promptinit" and "promptinit" are commented out. This doesnt seem to change anything though)

Last edited by Bladtman242 (2012-02-17 17:59:34)

Offline

#2 2012-02-15 04:29:59

daedhel
Member
From: Québec, Canada
Registered: 2009-01-17
Posts: 40
Website

Re: [SOLVED] zsh prompt colors misaligns the prompt

Have you tried to take out your prompt components one by one, each time testing it?

You might find your problem just like that.

That's what I did to resolve my zsh problems in the past.

Offline

#3 2012-02-15 23:15:40

Bladtman242
Member
Registered: 2012-02-14
Posts: 127

Re: [SOLVED] zsh prompt colors misaligns the prompt

Well, yeah actually. It's the colours big_smile
Adding a color in the left-hand prompt moves the right-hand prompt to far to the left.
Adding a color to the right-hand prompt misplaces the cursor hmm
Any suggestions? smile

EDIT: If I come across seeming a bit smug, it is unintended. Promise smile

Last edited by Bladtman242 (2012-02-15 23:18:54)

Offline

#4 2012-02-16 22:08:59

Bladtman242
Member
Registered: 2012-02-14
Posts: 127

Re: [SOLVED] zsh prompt colors misaligns the prompt

Actually, that can't be right. In the picture above, both problems occur, but I've only put colours in the right-hand prompt.
Still, the problem goes away when I remove the colours, and occurs when I add them again.

Offline

#5 2012-02-16 22:38:56

VCoolio
Member
From: Netherlands
Registered: 2010-01-05
Posts: 120

Re: [SOLVED] zsh prompt colors misaligns the prompt

How do you insert the color references? You need to surround those with escapes so the prompt doesn't count them as characters, like this:
%{color-reference-here%}prompt-element-here

Last edited by VCoolio (2012-02-16 22:43:36)

Offline

#6 2012-02-17 12:06:12

Bladtman242
Member
Registered: 2012-02-14
Posts: 127

Re: [SOLVED] zsh prompt colors misaligns the prompt

Ahh, a great many thanks to you, good sir.
The arch wiki states that using %{%} is "usefull", so I didn't realize how much it really did.
That solved it, thanks again smile

EDIT: How do I mark the thread as solved? smile

Last edited by Bladtman242 (2012-02-17 12:07:18)

Offline

#7 2012-02-17 12:40:27

Avant-texte
Member
Registered: 2012-02-13
Posts: 136

Re: [SOLVED] zsh prompt colors misaligns the prompt

Bladtman242 wrote:

How do I mark the thread as solved? smile

Edit your first post in the thread. You'll be able to edit the subject line too.

Offline

#8 2012-02-17 17:59:44

Bladtman242
Member
Registered: 2012-02-14
Posts: 127

Re: [SOLVED] zsh prompt colors misaligns the prompt

Thanks smile

Offline

#9 2012-02-17 21:10:43

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] zsh prompt colors misaligns the prompt

Bladtman242 wrote:

The arch wiki states that using %{%} is "usefull", so I didn't realize how much it really did.

Just wanted to suggest: If the wiki wasn't clear, improve it smile

Offline

#10 2012-02-17 21:28:08

Bladtman242
Member
Registered: 2012-02-14
Posts: 127

Re: [SOLVED] zsh prompt colors misaligns the prompt

Good point.
I actually just registered a user there earlier today, so now I will! smile

Last edited by Bladtman242 (2012-02-17 21:28:22)

Offline

Board footer

Powered by FluxBB