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

Ansi output is visible in shell when running hledger #2015

Closed
olimorris opened this issue Mar 25, 2023 · 9 comments
Closed

Ansi output is visible in shell when running hledger #2015

olimorris opened this issue Mar 25, 2023 · 9 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike. platform:mac

Comments

@olimorris
Copy link

olimorris commented Mar 25, 2023

When I run hledger in my terminal I'm seeing lots of ansi output:

Screen Shot 2023-03-25 at 12 37 22@2x

Additional information:

  • Installed via Homebrew
  • hledger 1.29.1, mac-aarch64
  • I am using Kitty 0.27.1 and tmux 3.3a
  • Running hledger test I see All 220 tests passed (0.04s)
  • Running echo $LANG I see en_GB.UTF-8
  • Trying this in the standard macOS Terminal.app also shows the same
@olimorris olimorris added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Mar 25, 2023
@simonmichael simonmichael added platform:mac cli Command line parsing, options, arguments and suchlike. labels Mar 25, 2023
@simonmichael
Copy link
Owner

Thanks for the report. If I understand rightly, you see this just running hledger in Apple's Terminal.app, with no tmux involved ?

As a temporary workaround you can export NO_COLOR=1 or alias hledger='hledger --color=no'.

@olimorris
Copy link
Author

Thanks for the report. If I understand rightly, you see this just running hledger in Apple's Terminal.app, with no tmux involved ?

That's correct. I'll try recreating in a GitHub Action too.

As a temporary workaround you can export NO_COLOR=1 or alias hledger='hledger --color=no'.

👍🏼️

@simonmichael
Copy link
Owner

Hmm, I can't reproduce then. How about in iTerm if you have that ? I wonder if I configured Terminal in some way I've forgotten ? Can anyone else reproduce ?

@simonmichael
Copy link
Owner

Macos Monterey 12.6.2 here.

@simonmichael
Copy link
Owner

I see.. it works for me because I have less configured to render ANSI sequences (LESS environment variable contains R). Hmm. Seeing the bold headings is pleasant, but I'm not sure if we can safely detect when to show them.

@simonmichael
Copy link
Owner

Workaround for now: perhaps export LESS=R$LESS fixes it ? I use export LESS=EFRSWX.

@simonmichael
Copy link
Owner

simonmichael commented Apr 6, 2023

We could:

  • show no ANSI ever by default, and require an opt-in HLEDGER_COLOR=1 var to turn it on. People doing that would be responsible for also configuring their $PAGER to show ANSI.
  • keep showing ANSI by default, and get Add the color flag to less pharpend/pager#1 released or ship it ourselves, so when it is sent to $PAGER there's a better chance it will work (it would call less -R or more, both of which apparently show ANSI). People who have PAGER customised to something else might still see the problem.
  • add R to $LESS in hledger's program environment at startup. Equivalent to the above ? Would solve the problem for the common case, but not for every possible custom PAGER.

simonmichael added a commit that referenced this issue Apr 6, 2023
…2015)

If you use some other $PAGER, you will have to configure it to show
ANSI yourself (or disable ANSI, eg by setting NO_COLOR=1).
@simonmichael
Copy link
Owner

I went with the third option - add R to $LESS (and $MORE) at startup. And added a https://hledger.org/dev/hledger.html#paging doc.

@olimorris
Copy link
Author

Thanks so much for persevering with this. Can confirm that trying export LESS=EFRSWX fixed it for me!

simonmichael added a commit that referenced this issue Apr 7, 2023
…2015)

If you use some other $PAGER, you will have to configure it to show
ANSI yourself (or disable ANSI, eg by setting NO_COLOR=1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike. platform:mac
Projects
None yet
Development

No branches or pull requests

2 participants