Comments (14)
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.
I've tried adding the \[
you mentioned around the color codes so for example:
local red_unstaged_prefix="\[\033[1;31m\]"
That gives:
seems the \[
is getting escaped
from git-radar.
Yep, seems some escaping problems. Need to dig it deeper!
from git-radar.
I wouldn't be surprised if my use of printf is messing things around.
from git-radar.
Thanks for the pull request btw
from git-radar.
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.
I have tested on my machine, escaping works fine. How did you received this 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.
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.
So if you use double quotes in your .bashrc
file my pull request works on your machine? Thanks!
from git-radar.
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.
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.
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.
Seems a very complicated thing. But works like a charm!
from git-radar.
Awesome, thanks for the help. Closing.
from git-radar.
Related Issues (20)
- is_cwd_a_dot_git_directory:1: = not found HOT 7
- Promote new Maintainers HOT 4
- Calling Formula.sha1 is deprecated! HOT 4
- Calling Formula.sha1 is deprecated! HOT 2
- Not upstream indicator taking up too much space HOT 12
- problem with fish HOT 2
- Weird issue with Makefile HOT 2
- Running git-radar --bash is slow HOT 3
- Fish - LS is completely bugged HOT 2
- command overlaps prompt with stash HOT 1
- odd sed error on branches named with multiple / characters HOT 7
- have to pull twice to update a work branch HOT 22
- Made a new lightweight stable version of git-radar HOT 2
- weird characters show up with git-radar on mac os x HOT 8
- fatal error messages with git-radar on local untracked branches HOT 11
- Unhandled git error when a tracked upstream branch is removed HOT 2
- 0.6 upgrade issue HOT 3
- feature req: color prompt red when folder not writable HOT 1
- Reduce the number of binaries needed to be added to the path HOT 3
- cd .git/ produces fatal: /usr/lib/git-core/git-stash cannot be used without a working tree HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-radar.