zsh-users
 help / Atom feed
* Prompt Issue
@ 2019-07-05  1:15 Zhao Li
  2019-07-05  7:05 ` Roman Perepelitsa
  0 siblings, 1 reply; 6+ messages in thread
From: Zhao Li @ 2019-07-05  1:15 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1.1: Type: text/plain, Size: 2680 bytes --]

Hi Folks,

I started using zsh with oh-my-zsh and things have been going great.  I am
able to customize my prompt, but am encountering this last quirk:

When I press tab to autocomplete/autosuggest, the prompt gets munched up.

I tried removing the emoji's and special characters, but the only time this
issue does not happen is when the git information is not displayed at all.

Attached are some screenshots of what’s happening.  Though I don't know if
email attachments show up on mailing lists or not.  If not, then the
screenshots can be found here as well:
https://github.com/robbyrussell/oh-my-zsh/issues/7945

This is my prompt configuration:
https://github.com/zhao-li/dots/blob/master/custom/themes/zhaoli.zsh-theme

Any ideas, how I can fix my prompt so tabbing out doesn’t munch the
prompt?  Or where else I can try to look to solve this issue?

Thank you for your time :)

[image: PromptIssue.png]

#!/bin/sh

# This configures the custom oh-my-zsh theme
# deferring to scripts/prompt.sh to handle setting the prompt
# https://github.com/robbyrussell/oh-my-zsh/blob/master/custom/themes/example.zsh-theme

color='%F{magenta}'
ZSH_THEME_GIT_PROMPT_PREFIX="$color("
ZSH_THEME_GIT_PROMPT_SUFFIX="$color)"
ZSH_THEME_GIT_PROMPT_BRANCH="$color"
ZSH_THEME_GIT_PROMPT_DIRTY='💩'
ZSH_THEME_GIT_PROMPT_CLEAN='🦄'
ZSH_THEME_GIT_PROMPT_AHEAD="$color↑"
ZSH_THEME_GIT_PROMPT_BEHIND="$color↓"

local user="%F{cyan}%n"
local dir="%F{green}%~%f"

# based off of:
https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git-prompt/git-prompt.plugin.zsh
git_info() {
  if [ -n "$__CURRENT_GIT_STATUS" ]; then
    STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}"
    if [ "$GIT_BEHIND" -ne "0" ]; then
        STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND%{${reset_color}%}"
    fi
    if [ "$GIT_AHEAD" -ne "0" ]; then
        STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD%{${reset_color}%}"
    fi
    if [ "$GIT_CHANGED" -ne "0" ] || [ "$GIT_UNTRACKED" -ne "0" ]; then
        STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_DIRTY%{${reset_color}%}"
    fi
    if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [
"$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then
        STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
    fi
    STATUS="$STATUS%{${reset_color}%}$ZSH_THEME_GIT_PROMPT_SUFFIX"
    echo "$STATUS"
  fi
}

PROMPT=$'$FG[237]-------------------------------------------------------------------------------%{$reset_color%}\n'
PROMPT+="${user}"
PROMPT+="${dir}"
PROMPT+='%{$(git_info)%}'
PROMPT+='%{${reset_color}%}$ '

RPROMPT=''

[-- Attachment #1.2: Type: text/html, Size: 3964 bytes --]

[-- Attachment #2: PromptIssue.png --]
[-- Type: image/png, Size: 43758 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prompt Issue
  2019-07-05  1:15 Prompt Issue Zhao Li
@ 2019-07-05  7:05 ` Roman Perepelitsa
  2019-07-05 11:05   ` Zhao Li
  2019-07-05 17:20   ` Grant Taylor
  0 siblings, 2 replies; 6+ messages in thread
From: Roman Perepelitsa @ 2019-07-05  7:05 UTC (permalink / raw)
  To: Zhao Li; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 181 bytes --]

This is the problem:

    PROMPT+='%{$(git_info)%}'

Fix:

   PROMPT+='$(git_info)'

I've provided more details in
https://github.com/robbyrussell/oh-my-zsh/issues/7945.

Roman.

>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prompt Issue
  2019-07-05  7:05 ` Roman Perepelitsa
@ 2019-07-05 11:05   ` Zhao Li
  2019-07-05 11:58     ` Roman Perepelitsa
  2019-07-05 17:20   ` Grant Taylor
  1 sibling, 1 reply; 6+ messages in thread
From: Zhao Li @ 2019-07-05 11:05 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

wow thank you so much for taking the time to write your post. Your example
code to fix the problem along with explanation helps tremendously. I can
understand why %{...%} is helpful here
<https://github.com/robbyrussell/oh-my-zsh/issues/2314#issuecomment-32155974>
 (
https://github.com/robbyrussell/oh-my-zsh/issues/2314#issuecomment-32155974),
but not where I was using it in my prompt.

Thank you also for pointing me to gitstatus and your detailed example code
for that as well.

I think I'm finally at a good place with my prompt and using zsh with
oh-my-zsh.

My last remaining issue is with hyper.js not properly handling emoji's and
causing the prompt to be off by one character
<https://github.com/zeit/hyper/issues/3516> (
https://github.com/zeit/hyper/issues/3516). Unless you know of some easy
fix for that as well, I'm going to just wait for hyper.js to fix that issue
ticket.

Thanks again for your time and effort.

On Thu, Jul 4, 2019 at 9:06 PM Roman Perepelitsa <
roman.perepelitsa@gmail.com> wrote:

> This is the problem:
>
>     PROMPT+='%{$(git_info)%}'
>
> Fix:
>
>    PROMPT+='$(git_info)'
>
> I've provided more details in
> https://github.com/robbyrussell/oh-my-zsh/issues/7945.
>
> Roman.
>
>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prompt Issue
  2019-07-05 11:05   ` Zhao Li
@ 2019-07-05 11:58     ` Roman Perepelitsa
  2019-07-06 15:52       ` Zhao Li
  0 siblings, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2019-07-05 11:58 UTC (permalink / raw)
  To: Zhao Li; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]

Let's have this discussion only in one place. I replied in
https://github.com/robbyrussell/oh-my-zsh/issues/7945.

Roman.

On Fri, Jul 5, 2019 at 1:05 PM Zhao Li <zhao.li@startingspark.com> wrote:

> wow thank you so much for taking the time to write your post. Your example
> code to fix the problem along with explanation helps tremendously. I can
> understand why %{...%} is helpful here
> <https://github.com/robbyrussell/oh-my-zsh/issues/2314#issuecomment-32155974>
>  (
> https://github.com/robbyrussell/oh-my-zsh/issues/2314#issuecomment-32155974),
> but not where I was using it in my prompt.
>
> Thank you also for pointing me to gitstatus and your detailed example code
> for that as well.
>
> I think I'm finally at a good place with my prompt and using zsh with
> oh-my-zsh.
>
> My last remaining issue is with hyper.js not properly handling emoji's
> and causing the prompt to be off by one character
> <https://github.com/zeit/hyper/issues/3516> (
> https://github.com/zeit/hyper/issues/3516). Unless you know of some easy
> fix for that as well, I'm going to just wait for hyper.js to fix that issue
> ticket.
>
> Thanks again for your time and effort.
>
> On Thu, Jul 4, 2019 at 9:06 PM Roman Perepelitsa <
> roman.perepelitsa@gmail.com> wrote:
>
>> This is the problem:
>>
>>     PROMPT+='%{$(git_info)%}'
>>
>> Fix:
>>
>>    PROMPT+='$(git_info)'
>>
>> I've provided more details in
>> https://github.com/robbyrussell/oh-my-zsh/issues/7945.
>>
>> Roman.
>>
>>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prompt Issue
  2019-07-05  7:05 ` Roman Perepelitsa
  2019-07-05 11:05   ` Zhao Li
@ 2019-07-05 17:20   ` Grant Taylor
  1 sibling, 0 replies; 6+ messages in thread
From: Grant Taylor @ 2019-07-05 17:20 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

On 7/5/19 1:05 AM, Roman Perepelitsa wrote:
> I've provided more details in
> https://github.com/robbyrussell/oh-my-zsh/issues/7945.

Thank you for the write up Roman.

I learned multiple unexpected things from it.  :-)



-- 
Grant. . . .
unix || die


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4008 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Prompt Issue
  2019-07-05 11:58     ` Roman Perepelitsa
@ 2019-07-06 15:52       ` Zhao Li
  0 siblings, 0 replies; 6+ messages in thread
From: Zhao Li @ 2019-07-06 15:52 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

Thanks Roman for all of your help.  I'm just posting a note here to close
this thread out in case anyone else finds this in the future.  The issue
ended up being how I was configuring zsh to understand the character widths
of the items in my prompt.  The full detail can be found on this thread:
https://github.com/robbyrussell/oh-my-zsh/issues/7945

Thank you again Roman!  I would have never been able to figure all of this
out because I didn't even know what to google for.  😅

On Fri, Jul 5, 2019 at 1:58 AM Roman Perepelitsa <
roman.perepelitsa@gmail.com> wrote:

> Let's have this discussion only in one place. I replied in
> https://github.com/robbyrussell/oh-my-zsh/issues/7945.
>
> Roman.
>
> On Fri, Jul 5, 2019 at 1:05 PM Zhao Li <zhao.li@startingspark.com> wrote:
>
>> wow thank you so much for taking the time to write your post. Your
>> example code to fix the problem along with explanation helps tremendously.
>> I can understand why %{...%} is helpful here
>> <https://github.com/robbyrussell/oh-my-zsh/issues/2314#issuecomment-32155974>
>>  (
>> https://github.com/robbyrussell/oh-my-zsh/issues/2314#issuecomment-32155974),
>> but not where I was using it in my prompt.
>>
>> Thank you also for pointing me to gitstatus and your detailed example
>> code for that as well.
>>
>> I think I'm finally at a good place with my prompt and using zsh with
>> oh-my-zsh.
>>
>> My last remaining issue is with hyper.js not properly handling emoji's
>> and causing the prompt to be off by one character
>> <https://github.com/zeit/hyper/issues/3516> (
>> https://github.com/zeit/hyper/issues/3516). Unless you know of some easy
>> fix for that as well, I'm going to just wait for hyper.js to fix that issue
>> ticket.
>>
>> Thanks again for your time and effort.
>>
>> On Thu, Jul 4, 2019 at 9:06 PM Roman Perepelitsa <
>> roman.perepelitsa@gmail.com> wrote:
>>
>>> This is the problem:
>>>
>>>     PROMPT+='%{$(git_info)%}'
>>>
>>> Fix:
>>>
>>>    PROMPT+='$(git_info)'
>>>
>>> I've provided more details in
>>> https://github.com/robbyrussell/oh-my-zsh/issues/7945.
>>>
>>> Roman.
>>>
>>>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05  1:15 Prompt Issue Zhao Li
2019-07-05  7:05 ` Roman Perepelitsa
2019-07-05 11:05   ` Zhao Li
2019-07-05 11:58     ` Roman Perepelitsa
2019-07-06 15:52       ` Zhao Li
2019-07-05 17:20   ` Grant Taylor

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox