I would like to set core.pager in order to manage long lines wrapping text. In order to do it I use this command:
$ GIT_PAGER="fold -sw $COLUMNS" git log
I tried to set core.pager, but Bash evaluate $COLUMNS too early:
$ git config core.pager "fold -sw $COLUMNS"
$ grep pager .git/config
pager = fold -sw 80
If I try to escape $COLUMNS, I get:
$ git config core.pager "fold -sw \$COLUMNS"
$ grep pager .git/config
pager = fold -sw $COLUMNS
$ LC_ALL=en_US git log
fold: option requires an argument -- 'w'
Try 'fold --help' for more information.
If I try to use sh -c
I get:
$ git config core.pager 'sh -c fold -sw $COLUMNS'
$ grep pager .git/config
pager = sh -c fold -sw $COLUMNS
..but it doesn't evaluate $COLUMNS correctly (it's static).
How could I get the same behavior of the first command I wrote setting it in core.pager?
Edit: as Nick Bastin has noted git config core.pager "fold -sw \$COLUMNS"
should work, but probably I've a problem with the child process.