so-fancy / diff-so-fancy

Good-lookin' diffs. Actually… nah… The best-lookin' diffs. :tada:
MIT License
17.28k stars 330 forks source link

No way to set the ruler width from the command line #495

Open ideasman42 opened 3 weeks ago

ideasman42 commented 3 weeks ago

The ruler width is either read from the terminal or from the git-config.

This means there is no way to conveniently set this from the command line which is needed when diff-so-fancy is not called from a terminal, see:

https://codeberg.org/ideasman42/emacs-diff-ansi

Similar tools (delta & ydiff) support setting the width from the command line.

scottchiefbaker commented 3 weeks ago

The width is read from the git config: https://github.com/so-fancy/diff-so-fancy?tab=readme-ov-file#rulerwidth

ideasman42 commented 3 weeks ago

@scottchiefbaker right, but for a diff-viewing tool, it doesn't make sense to modify the users git-config every time a diff is displayed (which would change based on the windows width).

scottchiefbaker commented 3 weeks ago

You can set it to an arbitrary width like 80 chars if you want, or let d-s-f calculate the window width on startup (the default). If you want to hardcode a width you can edit the diff-so-fancy script manually.

ideasman42 commented 3 weeks ago

In this case I'm using emacs to run diff-so-fancy as a sub-process, to read and display it's output. The width is known from emacs, however it can change based on emacs zoom level, so hard coding this doesn't make sense. Further, using tput within the sub-process doesn't make much sense as this isn't necessarily running from a terminal.

There is no terminal as this is using the standard output, so I need an argument to input width ( --width=99) (both ydiff & delta support this for e.g.).

scottchiefbaker commented 3 weeks ago

I just landed 0965029082fd56fbcc8219351eee3ccf9fd6c9d1 which adds a --rulerWidth X option to the CLI options.