blaCCkHatHacEEkr / PENTESTING-BIBLE

articles
https://twitter.com/cry__pto
MIT License
12.74k stars 2.33k forks source link

zsh tab completion messes up terminal #28

Open SkyperTHC opened 1 year ago

SkyperTHC commented 1 year ago

Tested on MacOS/Cygwin/Linux.

Using the default two line prompt with the skull-emoji. Problem is that zsh counts the length of the prompt for tab completion and the UTF characters mess with that counting. All UTF characters need to be wrapped in %{%G<UTC character%}.

How to reproduce:

docker run --rm  -it kalilinux/kali-rolling
apt update -y
apt install -y --no-install-recommends zsh
zsh -il

echo<TAB><TAB>

(e.g. write echo and then press TAB twice and observe how the prompt will get messed up.)

This fixes it (note the two UTF8 characters following the 'n'):

sed -i 's/\(\s*PROMPT=.*\)n└─\(.*\)/\1n%{%G└%}%{%G─%}\2/g' ~/.zshrc

I think this is actually a ZSH problem because people all over the Internet are crying that zsh tab completion messes up their prompt if they use emojis in their prompt (?).