Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Prompt escape sequences error #40

Closed
paxperscientiam opened this issue Dec 10, 2017 · 8 comments
Closed

[macOS] Prompt escape sequences error #40

paxperscientiam opened this issue Dec 10, 2017 · 8 comments

Comments

@paxperscientiam
Copy link

Hey there @jarun , great project!

Small bug i've noticed is that, after conducting a search, the ddgr prompt is a bit funny due to possible syntax error.

On my machine I get this literal string for the prompt: [7mddgr (? for help)[0m

The code, should be something like this: '\e[7mddgr (? for help)\e[0m

$ echo -e '\e[7mddgr (? for help)\e[0m'
=> ddgr (? for help)
@jarun
Copy link
Owner

jarun commented Dec 11, 2017

On my machine

Details please? OS, terminal, locale?

It's as per the color coding guidelines already so I am expecting your terminal has something in play here.

@paxperscientiam
Copy link
Author

paxperscientiam commented Dec 11, 2017 via email

@jarun
Copy link
Owner

jarun commented Dec 11, 2017

I believe this is the same as jarun/googler#203. We had a patch in and then we had to revert it back due to glaring side-effects. At this point we don't have any other graceful way to handle it. One way would be to disable readline but that would be telling on user experience.

@jarun
Copy link
Owner

jarun commented Dec 11, 2017

What do you see if you run the following python3 snippet?

#!/usr/bin/env python3
import readline

message = 'ddgr (? for help)'
prompt = '\x1b[7m' + message + '\x1b[0m' + ' '
try:
    cmd = input(prompt)
except EOFError:
    sys.exit(0)

@jarun
Copy link
Owner

jarun commented Dec 11, 2017

Given this is the second time this issue is reported, I am working on a way to handle this. I will add the support for an environment variable, which, if defined, will render a plain prompt. Even if the issue is not widespread, it can put-off several users... so it's better to have a way to avoid it.

@jarun jarun closed this as completed in 8f76b94 Dec 11, 2017
@paxperscientiam
Copy link
Author

paxperscientiam commented Mar 17, 2018

Hey @jarun , I know I meant to response ... but obviously I forgot!

Running your snippet with python3 yield this:

7mddgr (? for help)[0m

EDIT: I just tried the dev release and the result is the same.

EDIT2: To be perfectly clear, it's definitely not the terminal emulator (iTerm2) nor the environment. The escape sequences are interpreted properly when used in bash.

message='ddgr (? for help)'
printf '\x1b[7m%s\x1b[0m' "${message}"

This gives the expected inverted colored face/background.

EDIT: @jarun solved! I did not have the proper python readline extension installed. So...maybe you just need to test for that?

@jarun
Copy link
Owner

jarun commented Mar 17, 2018

We have introduced a new env var to disable the prompt color:

export DISABLE_PROMPT_COLOR=1

It should work in all cases whatever the readline version is.

@paxperscientiam
Copy link
Author

With that said, one could set an alias like this:
alias ddgr='DISABLE_PROMPT_COLOR=1 ddgr'

@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants