bat icon indicating copy to clipboard operation
bat copied to clipboard

Tab's not shown with -d --tabs 0

Open abbaswasim opened this issue 2 years ago • 12 comments

IIUC in diff -d mode if I pass --tabs 0 it should display tabs as it is but in my terminals (iTerm2 and Terminal) its converting those to spaces. This (--tabs = 0) is also what delta uses to display tabs and it seems to have the same problem.

I can verify my file has tabs by using cat or bat -A as you can see in the attached image.

Screenshot 2022-05-13 at 11 21 10

I know bat is printing spaces because if I copy the content of my terminal after bat prints it and past it into sublime text, I can see the spaces. Attached image for reference.

Screenshot 2022-05-13 at 11 23 46

abbaswasim avatar May 13 '22 10:05 abbaswasim

Side note: it's good that you've ruled out your terminal converting tabs to spaces when copying, as some of them do that.

LoganDark avatar May 14 '22 23:05 LoganDark

Indeed. I have been looking through iTerm settings. There are a few things related to tabs stops but AFAICT I couldn’t find anything that talks about conversion. And either way it won’t just apply to bat.

abbaswasim avatar May 15 '22 09:05 abbaswasim

It might also be the pager (less) which converts tabs. Can you try with --paging=never/-P?

I don't think this is related to -d/--diff

sharkdp avatar May 15 '22 19:05 sharkdp

--paging=never and -P doesn't help.

abbaswasim avatar May 15 '22 19:05 abbaswasim

I can not reproduce this. Works for me with -P.

Can you please post the output of bat --diagnostic in order for us to get more information about your system?

sharkdp avatar May 15 '22 19:05 sharkdp

Software version

bat 0.20.0

Operating system

macOS 11.6.5 (Darwin 20.6.0)

Command-line

bat --diagnostic

Environment variables

SHELL=/bin/zsh
PAGER=less
LESS=-R
LANG=en_GB.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=0
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER=<not set>

Config file

Could not read contents of '/Users/abbaswasim/.config/bat/config': No such file or directory (os error 2).

Compile time information

  • Profile: release
  • Target triple: x86_64-apple-darwin
  • Family: unix
  • OS: macos
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2,sse3,ssse3
  • Host: x86_64-apple-darwin

Less version

> less --version
less 487 (POSIX regular expressions)
Copyright (C) 1984-2016  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less

abbaswasim avatar May 15 '22 20:05 abbaswasim

By the way I have also tried it in bash same behaviour.

abbaswasim avatar May 15 '22 20:05 abbaswasim

--paging=never and -P doesn't help.

Okay. And does it only happen with -d/--diff?

sharkdp avatar May 22 '22 10:05 sharkdp

No just bat has the same behavior. I originally saw this while using delta And then I thought delta must be using ‘bat’s diff version so tried that. But as you said in one of your earlier comments it’s not diff Related

abbaswasim avatar May 22 '22 11:05 abbaswasim

Actually scratch that. The reason I was using diff with tabs 0 Is because just bat on its own always prints spaces and that’s the default behavior it prints tabs only with ‘-A` AFAIK

abbaswasim avatar May 22 '22 11:05 abbaswasim

@abbaswasim Can you please summarize the current state? is this still a problem?

sharkdp avatar Sep 06 '22 21:09 sharkdp

@sharkdp the status hasn't changed. The issue is still there. Its a problem for me because I can't see tab to spaces or spaces to tabs changes in my git diffs.

In summary:

bat --tabs 0 shouldn't convert tabs in a file to spaces and it does.

abbaswasim avatar Sep 07 '22 10:09 abbaswasim