Giter Site home page Giter Site logo

Comments (14)

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Ah, interesting. I don't fully color codes so I've only done what I can to get it working. Can you suggest fixes that would solve this? The docs online are very dense so hard to grasp.

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

I've tried adding the \[ you mentioned around the color codes so for example:

local red_unstaged_prefix="\[\033[1;31m\]"

That gives:

screen shot 2015-08-26 at 12 26 40

seems the \[ is getting escaped

from git-radar.

grigoryvp avatar grigoryvp commented on July 20, 2024

Yep, seems some escaping problems. Need to dig it deeper!

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

I wouldn't be surprised if my use of printf is messing things around.

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Thanks for the pull request btw

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Using: printf '%q' $(./../git-radar/git-radar --bash) I get:

\\[\E[1;30m\\]git:(\\[\E[0m\\]\\[\E[0;37m\\]master\\[\E[0m\\]\\[\E[1;30m\\])\\[\E[0m\\]

So the \ is getting escaped at some point

from git-radar.

grigoryvp avatar grigoryvp commented on July 20, 2024

I have tested on my machine, escaping works fine. How did you received this screenshot?

screenshot

Please note, that "[" and "]" is a PS1-specific magic, it will not work if just printed from terminal

Can you please check #7 on your machine?

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Figured it out, I had my .bashrc set to:

export PS1='\W$(~/Projects/personal/git-radar/git-radar --bash) '

The correct way is:

export PS1="\W$(~/Projects/personal/git-radar/git-radar --bash) "

I.E. the ' should be ".

from git-radar.

grigoryvp avatar grigoryvp commented on July 20, 2024

So if you use double quotes in your .bashrc file my pull request works on your machine? Thanks!

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Actually it looks like it doesn't work right. So if I use ' then the prompt gets evaluated every time it renders. If I use " git-radar only renders the once, when the prompt first renders. .bashrc doesn't seem to be re-evaluated.

This might be my machine causing issues. Can you drop me your line where you set your PS1?

from git-radar.

grigoryvp avatar grigoryvp commented on July 20, 2024

Indeed where are weird things. If used double quotes escape codes work correct but evaluates only once (by standard actually), and with single quotes they are messed up.

But it's something inside string returned by git-radar that mess string. If I use:

export PS1='\[\e[37m\]\W\[\e[32m\]foo\[\e[33m\] \$ \[\e[37m\]'

scape codes work fine. But if git-radar is added, its messed up:

export PS1='\[\e[37m\]\W\[\e[32m\]$(~/Documents/git-radar/git-radar --bash --fetch)\[\e[33m\] \$ \[\e[37m\]'

I don't know why this happens :(

So i used a hack that allows to use double quotes in realtime. This makes things work:

make_prompt () {
  PS1="\[\e[37m\]\W\[\e[32m\]$(~/Documents/git-radar/git-radar --bash --fetch)\[\e[33m\] \$ \[\e[37m\]"
}
export PROMPT_COMMAND='make_prompt'

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Ok, so this superuser question explains it. PS1 converts \[ to \x01 and \] to \x02.

When you use ' to ensure your prompt gets evaluated each time, or use a \ to escape the $ in your PS1 for the same purpose:

export PS1="\$(git-radar --bash)"

then the PS1 doesn't get the chance to convert \[ to \x01 etc. The fix is to do the conversion ourselves.

I've pushed a pull request #11, can you check if that works for you? It works for me both in:

export PS1='\W\$(~/Projects/personal/git-radar/git-radar --bash) '

and

export PS1="\W$(~/Projects/personal/git-radar/git-radar --bash) "

from git-radar.

grigoryvp avatar grigoryvp commented on July 20, 2024

Seems a very complicated thing. But works like a charm!

from git-radar.

michaeldfallen avatar michaeldfallen commented on July 20, 2024

Awesome, thanks for the help. Closing.

from git-radar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.