This is the script I am using to make VSCode a pager:
#!/bin/bash
FILE=$(mktemp pager.XXXXXX.ansi)
cat > $FILE
code --wait $FILE
rm $FILE
When I run git log, it does as I intend and opens a preview window in VSCode with colors etc. This is helpful for me as I don't want to have to expand the integrated terminal and would rather a window would open with long-form command output. However, this doesn't work with man.
If I run man man, I can see the temporary file get created, but the temporary file just gets promptly deleted with VSCode never opening. I tried looking online for resources and also argued with Copilot with no avail. I could accept that it doesn't work with man if I only knew why. My speculation is that man creates an environment that can't spawn vscode.