Page MenuHomePhabricator

Terminology and fancy zsh (omz) prompt tab complete random characters
Open, Incoming QueuePublic

Description

When typing a command and using tab/auto completion, usually the bare minimum of the 1st character is duplicated, and the alignment of all characters thereafter are thrown off. Additionally, if I am editing a multi-line 'one liner', and I have tried to move beyond the line feed (non terminating), it can also mess up the character reference points.

Not sure what else to say to describe it, unfortunately the second behavior is much harder to capture in a screenshot since it just loses positioning and still displays the characters, but the cursor position in relation to the characters themselves is off...

Using OMZ/ZSH, powerline, and a very fancy prompt (attached below)

## My zsh theme.  Based on snippets from numerous different creators.
## Original content is created by SJL, Robby Russell, Mark Nichols
#
# Prompt has a 2 line output format, and works with SVN and Git
# Very multi colored, with a large amount of data exposed
# {Day Mon DD HH:MM:ss} (USER@shorthost)               REPO INFO
# [PATH] PRIVS

function prompt_char {
	git branch >/dev/null 2>/dev/null && echo '±' && return
	hg root >/dev/null 2>/dev/null && echo '☿' && return
	svn info >/dev/null 2>/dev/null && echo '⚡' && return
	echo '○'
}

# ----------------------------------------------------------------------------
# git prompt variables
# depends on using Steve Losh fork of oh-my-zsh
# ----------------------------------------------------------------------------
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_no_bold[magenta]%}Branch%{$fg_bold[black]%}: %{$fg_bold[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_no_bold[magenta]%}Status%{$fg_bold[black]%}: %{$fg_bold[magenta]%}dirty%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED=" %{$fg_no_bold[magenta]%}Status%{$fg_bold[black]%}: %{$fg_bold[magenta]%}untracked%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg_no_bold[magenta]%}Status%{$fg_bold[black]%}: %{$fg_bold[magenta]%}no-change%{$reset_color%}"

# ----------------------------------------------------------------------------
# svn prompt
# based on: https://gist.github.com/1156969 
# with help from: http://andrewray.me/bash-prompt-builder/index.html
# ----------------------------------------------------------------------------
function svn_prompt_info {
# Set up defaults
	local svn_branch=""
	local svn_repository=""
	local svn_version=""
	local svn_change=""

	# only if we are in a directory that contains a .svn entry
	if [ -d ".svn" ]; then
		# query svn info and parse the results
		svn_branch=`svn info | grep '^URL:' | egrep -o '((tags|branches)/[^/]+|trunk).*' | sed -E -e 's/^(branches|tags)\///g'`
		svn_repository=`svn info | grep '^Repository Root:' | egrep -o '(http|https|file|svn|svn+ssh)/[^/]+' | egrep -o '[^/]+$'`
		svn_version=`svnversion -n`

		# this is the slowest test of the bunch
		change_count=`svn status | grep "?\|\!\|M\|A" | wc -l`
		if [ "$change_count" != "       0" ]; then
			svn_change="dirty"
		else
			svn_change="no-change"
		fi

		# show the results
		echo " %{$fg_bold[magenta]%}Repository%{$fg_bold[green]%}: %{$fg_bold[magenta]%}$svn_repository %{$fg_bold[magenta]%}Branch%{$fg_bold[green]%}: %{$fg_bold[magenta]%}$svn_branch %{$fg_bold[magenta]%}Version%{$fg_bold[green]%}: %{$fg_bold[magenta]%}$svn_version %{$fg_bold[magenta]%}Status%{$fg_bold[green]%}: %{$fg_bold[magenta]%}$svn_change%{$reset_color%}"

	fi
}

function hg_prompt_info {
hg prompt --angle-brackets " %{$fg_bold[magenta]%}Branch%{$fg_bold[green]%}: %{$fg_bold[magenta]%}<branch> %{$fg_bold[magenta]%}Tags%{$fg_bold[green]%}: %{$fg_bold[magenta]%}<tags> %{$fg_bold[magenta]%}Count%{$fg_bold[green]%}: %{$fg_bold[magenta]%}<count> %{$fg_bold[magenta]%}Status%{$fg_bold[green]%}: %{$fg_bold[magenta]%}<status> %{$fg_bold[magenta]%}Update%{$fg_bold[green]%}: %{$fg_bold[magenta]%}<update>%{$reset_color%}" 2>/dev/null
} 

MODE_INDICATOR="%{$fg_bold[green]%}[%{$fg_no_bold[magenta]%}CMD%{$fg_bold[green]%}]%{$reset_color%}"

PROMPT='%{$fg_bold[green]%}┌[%{$fg_no_bold[blue]%}%D{%a %b %e} %*%{$fg_bold[green]%}]-(%{$fg_no_bold[white]%}%n%{$fg_bold[green]%}@%{$fg_bold[white]%}%m%{$fg_bold[green]%})-%{$fg_bold[green]%}[%{$fg_no_bold[cyan]%}$(prompt_char)%{$fg_bold[green]%}]$(git_prompt_info)$(svn_prompt_info)$(hg_prompt_info)%{$reset_color%}
%{$fg_bold[green]%}└[%{$fg_no_bold[magenta]%}%~%{$fg_bold[green]%}]>%{$reset_color%} '
Daemoen created this task.Jan 9 2017, 9:52 PM

Could you test with one of the pre-release tarball: https://download.enlightenment.org/pre-releases/ ?

Tested it with the latest one from Jan 17, can reproduce still. ./configure; make. cd src/bin; ./terminology; and start tab completing a command that begins with 'a' and it becomes aa immediately.

Also -- If you are unable to reproduce, let me know and we can do a jitsi/gtm or something so you can see what is actually happening.

Could you give me your zsh configuration?

The entire config might be harder to do, but i use oh-my-zsh with my theme above as a custom theme

my zshrc is:

# Path to your oh-my-zsh installation.
export ZSH=~/personal/dotfiles/omz

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.

# PowerLine for ZSH
ZSH_THEME="powerline"

# Powerline Options
POWERLINE_RIGHT_A="mixed"
POWERLINE_SHORT_HOST_NAME="true"
POWERLINE_DETECT_SSH="true"
MODE_INDICATOR="%{$fg_bold[green]%}[%{$fg_no_bold[magenta]%}CMD%{$fg_bold[green]%}]%{$reset_color%}"

# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Uncomment the following line to use case-sensitive completion.
CASE_SENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to disable command auto-correction.
# DISABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
ZSH_CUSTOM=~/personal/dotfiles/custom

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(colorize dirpersist extract git history new-gpg-agent rsync vi-mode)

source ${ZSH}/oh-my-zsh.sh
source ~/personal/dotfiles/universal/setup

# User configuration

export PATH=${HOME}/bin:/usr/local/bin:/usr/local/heroku/bin:${PATH}
# export MANPATH="/usr/local/man:${MANPATH}"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

export LC_ALL="en_US.UTF-8"

And a slight correction to the above, forgot I made a different theme as well:

# FreeAgent puts the powerline style in zsh !

if [ "$POWERLINE_DATE_FORMAT" = "" ]; then
  POWERLINE_DATE_FORMAT="?  %D{%Y-%m-%d}"
fi

if [ "$POWERLINE_RIGHT_B" = "" ]; then
  POWERLINE_RIGHT_B="⌚ %D{%H:%M:%S}"
elif [ "$POWERLINE_RIGHT_B" = "none" ]; then
  POWERLINE_RIGHT_B=""
fi

if [ "$POWERLINE_RIGHT_A" = "mixed" ]; then
  POWERLINE_RIGHT_A=%(?."$POWERLINE_DATE_FORMAT".%F{red}✘ %?)
elif [ "$POWERLINE_RIGHT_A" = "exit-status" ]; then
  POWERLINE_RIGHT_A=%(?.%F{green}✔ %?.%F{red}✘ %?)
elif [ "$POWERLINE_RIGHT_A" = "exit-status-on-fail" ]; then
  POWERLINE_RIGHT_A=%(?..%F{red}✘ %?)
elif [ "$POWERLINE_RIGHT_A" = "date" ]; then
  POWERLINE_RIGHT_A="$POWERLINE_DATE_FORMAT"
fi

if [ "$POWERLINE_SHORT_HOST_NAME" = "" ]; then
    POWERLINE_HOST_NAME="%M"
else
    POWERLINE_HOST_NAME="%m"
fi

if [ "$POWERLINE_HIDE_USER_NAME" = "" ] && [ "$POWERLINE_HIDE_HOST_NAME" = "" ]; then
    POWERLINE_USER_NAME="%n@$POWERLINE_HOST_NAME"
elif [ "$POWERLINE_HIDE_USER_NAME" != "" ] && [ "$POWERLINE_HIDE_HOST_NAME" = "" ]; then
    POWERLINE_USER_NAME="@$POWERLINE_HOST_NAME"
elif [ "$POWERLINE_HIDE_USER_NAME" = "" ] && [ "$POWERLINE_HIDE_HOST_NAME" != "" ]; then
    POWERLINE_USER_NAME="%n"
else
    POWERLINE_USER_NAME=""
fi

if [ "$POWERLINE_PATH" = "full" ]; then
  POWERLINE_PATH="%1~"
elif [ "$POWERLINE_PATH" = "short" ]; then
  POWERLINE_PATH="%~"
else
  POWERLINE_PATH="%d"
fi

if [ "$POWERLINE_CUSTOM_CURRENT_PATH" != "" ]; then
  POWERLINE_CURRENT_PATH="$POWERLINE_CUSTOM_CURRENT_PATH"
fi

if [ "$POWERLINE_GIT_CLEAN" = "" ]; then
  POWERLINE_GIT_CLEAN="✔"
fi

if [ "$POWERLINE_GIT_DIRTY" = "" ]; then
  POWERLINE_GIT_DIRTY="✘"
fi

if [ "$POWERLINE_GIT_ADDED" = "" ]; then
  POWERLINE_GIT_ADDED="%F{green}✚%F{black}"
fi

if [ "$POWERLINE_GIT_MODIFIED" = "" ]; then
  POWERLINE_GIT_MODIFIED="%F{blue}✹%F{black}"
fi

if [ "$POWERLINE_GIT_DELETED" = "" ]; then
  POWERLINE_GIT_DELETED="%F{red}✖%F{black}"
fi

if [ "$POWERLINE_GIT_UNTRACKED" = "" ]; then
  POWERLINE_GIT_UNTRACKED="%F{yellow}✭%F{black}"
fi

if [ "$POWERLINE_GIT_RENAMED" = "" ]; then
  POWERLINE_GIT_RENAMED="➜"
fi

if [ "$POWERLINE_GIT_UNMERGED" = "" ]; then
  POWERLINE_GIT_UNMERGED="═"
fi

if [ "$POWERLINE_RIGHT_A_COLOR_FRONT" = "" ]; then
  POWERLINE_RIGHT_A_COLOR_FRONT="white"
fi

if [ "$POWERLINE_RIGHT_A_COLOR_BACK" = "" ]; then
  POWERLINE_RIGHT_A_COLOR_BACK="black"
fi

ZSH_THEME_GIT_PROMPT_PREFIX=" \ue0a0 "
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY=" $POWERLINE_GIT_DIRTY"
ZSH_THEME_GIT_PROMPT_CLEAN=" $POWERLINE_GIT_CLEAN"

ZSH_THEME_GIT_PROMPT_ADDED=" $POWERLINE_GIT_ADDED"
ZSH_THEME_GIT_PROMPT_MODIFIED=" $POWERLINE_GIT_MODIFIED"
ZSH_THEME_GIT_PROMPT_DELETED=" $POWERLINE_GIT_DELETED"
ZSH_THEME_GIT_PROMPT_UNTRACKED=" $POWERLINE_GIT_UNTRACKED"
ZSH_THEME_GIT_PROMPT_RENAMED=" $POWERLINE_GIT_RENAMED"
ZSH_THEME_GIT_PROMPT_UNMERGED=" $POWERLINE_GIT_UNMERGED"
ZSH_THEME_GIT_PROMPT_AHEAD=" ⬆"
ZSH_THEME_GIT_PROMPT_BEHIND=" ⬇"
ZSH_THEME_GIT_PROMPT_DIVERGED=" ⬍"

# if [ "$(git_prompt_info)" = "" ]; then
   # POWERLINE_GIT_INFO_LEFT=""
   # POWERLINE_GIT_INFO_RIGHT=""
# else
    if [ "$POWERLINE_SHOW_GIT_ON_RIGHT" = "" ]; then
        if [ "$POWERLINE_HIDE_GIT_PROMPT_STATUS" = "" ]; then
            POWERLINE_GIT_INFO_LEFT=" %F{blue}%K{white}"$'\ue0b0'"%F{white}%F{black}%K{white}"$'$(git_prompt_info)$(git_prompt_status)%F{white}'
        else
            POWERLINE_GIT_INFO_LEFT=" %F{blue}%K{white}"$'\ue0b0'"%F{white}%F{black}%K{white}"$'$(git_prompt_info)%F{white}'
        fi
        POWERLINE_GIT_INFO_RIGHT=""
    else
        POWERLINE_GIT_INFO_LEFT=""
        if [ "$POWERLINE_HIDE_GIT_PROMPT_STATUS" = "" ]; then
            POWERLINE_GIT_INFO_RIGHT="%F{white}"$'\ue0b2'"%F{black}%K{white}"$'$(git_prompt_info)$(git_prompt_status)'" %K{white}"
        else
            POWERLINE_GIT_INFO_RIGHT="%F{white}"$'\ue0b2'"%F{black}%K{white}"$'$(git_prompt_info)'" %K{white}"
        fi
    fi
# fi

if [ $(id -u) -eq 0 ]; then
    POWERLINE_SEC1_BG=%K{red}
    POWERLINE_SEC1_FG=%F{red}
else
    POWERLINE_SEC1_BG=%K{cyan}
    POWERLINE_SEC1_FG=%F{cyan}
fi
POWERLINE_SEC1_TXT=%F{white}
if [ "$POWERLINE_DETECT_SSH" != "" ]; then
  if [ -n "$SSH_CLIENT" ]; then
    POWERLINE_SEC1_BG=%K{red}
    POWERLINE_SEC1_FG=%F{red}
    POWERLINE_SEC1_TXT=%F{white}
  fi
fi
PROMPT="$POWERLINE_SEC1_BG$POWERLINE_SEC1_TXT $POWERLINE_USER_NAME %k%f$POWERLINE_SEC1_FG%K{blue}"$'\ue0b0'"%k%f%F{white}%K{blue} "$POWERLINE_PATH"%F{blue}"$POWERLINE_GIT_INFO_LEFT" %k"$'\ue0b0'"%f "

if [ "$POWERLINE_NO_BLANK_LINE" = "" ]; then
    PROMPT="
"$PROMPT
fi

if [ "$POWERLINE_DISABLE_RPROMPT" = "" ]; then
    if [ "$POWERLINE_RIGHT_A" = "" ]; then
        RPROMPT="$POWERLINE_GIT_INFO_RIGHT%F{white}"$'\ue0b2'"%k%F{black}%K{white} $POWERLINE_RIGHT_B %f%k"
    elif [ "$POWERLINE_RIGHT_B" = "" ]; then
        RPROMPT="$POWERLINE_GIT_INFO_RIGHT%F{white}"$'\ue0b2'"%k%F{$POWERLINE_RIGHT_A_COLOR_FRONT}%K{$POWERLINE_RIGHT_A_COLOR_BACK} $POWERLINE_RIGHT_A %f%k"
    else
        RPROMPT="$POWERLINE_GIT_INFO_RIGHT%F{white}"$'\ue0b2'"%k%F{black}%K{white} $POWERLINE_RIGHT_B %f%F{$POWERLINE_RIGHT_A_COLOR_BACK}"$'\ue0b2'"%f%k%K{$POWERLINE_RIGHT_A_COLOR_BACK}%F{$POWERLINE_RIGHT_A_COLOR_FRONT} $POWERLINE_RIGHT_A %f%k"
    fi
fi

Which theme are you using? this one or the first one you gave me? Do you put those under custom/ and voilà?

My apologies for the confusion --

The correct theme is 'powerline' as indicated in the zshrc.

You should be able to load it in custom/ as you believed and it should be fine.

I am able to reproduce your issue on a fedora 25 in a docker. I'll try to work on it soon but probably after the 1.0.0 release.

Have you tested with xterm? Here, xterm behaves the same as terminology.

I had not tested with XTerm, I have tested against the other environment editors; ie -- Gnome Terminal, Konsole, Yakuake, Terminator; havent tested xfce's yet, i can do that as well if needed

jaawerth added a subscriber: jaawerth.EditedApr 30 2018, 9:29 PM

I realize I'm commenting over a year later, but figured I'd add some notes since I encountered this and sought out the issue:

I've been giving terminology and a spin, and can verify the same behavior with zprezto using 1.1.1 with the cloud theme. Switching to another theme, such as steeef, works. Tried a few others and so far it's only the cloud theme. However, the same theme works fine in xterm and my other go-to terminals (guake and terminator), as well as kitty. Hope that helps!