From: Ben Beltran Date: Thu, 20 Feb 2020 22:55:47 +0000 (+0100) Subject: Deal with double width chars X-Git-Url: https://git.r.bdr.sh/rbdr/dotfiles/commitdiff_plain/ec48932ff896ba580d9d9039d990a7cbd05eb549?hp=--cc Deal with double width chars --- ec48932ff896ba580d9d9039d990a7cbd05eb549 diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh index f0a776d..b21a41f 100644 --- a/zsh/modules/prompt.zsh +++ b/zsh/modules/prompt.zsh @@ -22,7 +22,7 @@ function virtualenv_info { else venv="${VIRTUAL_ENV##*/}" fi - echo "🐍${venv}" + echo "🐍 ${venv}" } function rvm_info { @@ -31,7 +31,7 @@ function rvm_info { else rvminfo=`rvm-prompt` fi - echo "💎${rvminfo}" + echo "💎 ${rvminfo}" } function nvm_info { @@ -40,7 +40,7 @@ function nvm_info { else nvminfo=`nvm current` fi - echo "💛${nvminfo}" + echo "💛 ${nvminfo}" } function box_name { @@ -52,15 +52,28 @@ function box_name { # function zle-line-init zle-keymap-select { - local return_status="%{%F{red}%}%(?..🆇)%{$reset_color%}" + + # Couldn't figure out how to get tmux and iTerm to agree on how to render + # these characters... so there you go. + + local normal_symbol="🅽" + local insert_symbol="🅸" + local error_symbol="🆇" + + [ ! -z "$TMUX" ] && normal_symbol="%{$normal_symbol%2G%}" + [ ! -z "$TMUX" ] && insert_symbol="%{$insert_symbol%2G%}" + [ ! -z "$TMUX" ] && error_symbol="%{$error_symbol%2G%}" + + # Show vi status / return status on the right side + + local return_status="%{%F{red}%}%(?.. $error_symbol)%{$reset_color%}" if [ $KEYMAP = 'vicmd' ]; then - local edit_status="%{%F{cyan}%}🅽" + local edit_status="%{%F{cyan}%}$normal_symbol" else - local edit_status="%{%F{green}%}🅸" + local edit_status="%{%F{green}%}$insert_symbol" fi - RPS1="${edit_status} ${return_status} %{$reset_color%}" - RPS2=$RPS1 + RPROMPT="${edit_status}${return_status}%{$reset_color%}" zle reset-prompt } zle -N zle-line-init @@ -100,3 +113,5 @@ function prompt_setup { prompt_setup "$@" setopt PROMPT_SUBST +setopt PROMPT_PERCENT +setopt TRANSIENT_RPROMPT