Comments (7)
Looks like man
uses MANPAGER
even when not connected to a terminal, which isn't what I would expect, but works to our advantage as a straightforward solution.
from vim-fugitive.
Relevant, and perhaps helpful: https://stackoverflow.com/questions/60106514/
from vim-fugitive.
This works fine on Linux, and I could have sworn it used to work fine on macOS. I wonder if something changed.
https://unix.stackexchange.com/questions/13267/how-to-disable-styling-on-man-pages demonstrates the behavior I expect: ASCII style formatting is disabled when TERM=dumb
. Making Fugitive responsible for cleaning it up is inconvenient, to say the least.
from vim-fugitive.
I agree it doesn't make sense for Fugitive to mess around with control bytes.
I can see three possible fixes:
- [always] set
TERM=dumb
or pipe throughcol -b
, if this doesn't cause other problems - [always] wrap
man
in a shell script, put the wrapper in a temp dir, and put the temp dir at the front of the$PATH
when invokinggit
- [conditional] detect
--help
(but presumably not after--
) and conditionally useTERM
orcol
Obviously some of this doesn't make sense on Windows or other non-POSIXy platforms.
The wrapper script might look like this:
#!/usr/bin/env sh
TERM=dumb /path/to/real/man $@
(My shell script is rusty; take this with a grain of salt.)
I'm willing to help in principle, but I'm not experienced with VIm scripting.
from vim-fugitive.
I agree it doesn't make sense for Fugitive to mess around with control bytes.
I can see three possible fixes:
- [always] set
TERM=dumb
or pipe throughcol -b
, if this doesn't cause other problems
We do always set TERM=dumb
. The problem is that on macOS, TERM=dumb
is ignored.
Always setting col -b
feels like a bad idea. For other commands, I don't want to be perpetually unsure if the output is mangled or not.
- [always] wrap
man
in a shell script, put the wrapper in a temp dir, and put the temp dir at the front of the$PATH
when invokinggit
This is probably the least worst option. Inconvenient but not impossible. There's also man.man.path
that could be pointed at the wrapper script to avoid getting PATH
involved.
- [conditional] detect
--help
(but presumably not after--
) and conditionally useTERM
orcol
We already detect --help
, so that part's fine. But conditionally using col
means we can't just directly execute git
, we need to involve the shell. This is more disruptive than the last one.
Obviously some of this doesn't make sense on Windows or other non-POSIXy platforms.
This complicates the implementation, and is part of the "inconvenient", but not a deal breaker.
The wrapper script might look like this:
#!/usr/bin/env sh TERM=dumb /path/to/real/man $@
What is /path/to/real/man
here? If there's another man
we could call that does the right thing, we could do away with the wrapper script entirely, and it gets a lot less annoying.
from vim-fugitive.
What is /path/to/real/man here? If there's another man we could call that does the right thing, we could do away with the wrapper script entirely, and it gets a lot less annoying.
The idea of using a separate script was that we could set TERM
(or pipe man output through col -b
) without impacting output from git itself – if git doesn't invoke man
, the script is never executed and nothing changes.
If you can pass git a config setting (you mentioned man.man.path
) to invoke a wrapper script by path, there's no need to "spell out" the path to man
in the script, in which case the 2nd line would become TERM=dumb man $@
rather than TERM=dumb /path/to/man $@
.
- If you need to find
/path/to/man
(i.e., the path to the system'sman
) – and it sounds like you don't – you'd probably choose to capture the output ofwhich man
prior to altering the$PATH
to include the directory enclosing the wrapper.
Taking all of that into account, it sounds like the best approach might be (pseudo-code):
$script_path := new_temporary_file_path()
write this literal to $script_path:
#!/usr/bin/env sh
TERM=dumb man $@ | col -b # presumably, on any given platform, either `TERM` or `col -b` will do the trick
when it's time to invoke git:
run "git -c man.man.path=" + shell_escape($script_path) + " <usual git arguments>"
from vim-fugitive.
That works beautifully! Thank you, @tpope!
from vim-fugitive.
Related Issues (20)
- Completion of the commit hash in cmdline? HOT 2
- Do not open quickfix on `:G difftool`
- Option to disable winfixbuf. HOT 6
- [Feature request] Allow custom format string for status buffer log lines HOT 1
- file does not belong to a Git repository. issue still there
- issue still there HOT 3
- `Git difftool -y` reports errors about newly created files
- [Question] Look-around branch autocompletion
- support for difftastic HOT 1
- :Gedit and similar commands spawn non-persistent buffers HOT 2
- confusing section folding toggle behavior
- Is there a way to "force" color to be enabled for a Git command that just loads a split? HOT 2
- Git Commit Showing Empty COMMIT_EDITMSG HOT 1
- `:Git stash list` does nothing when the stash is empty HOT 1
- Partial hunk staging doesn't work with nvim as EDITOR environment variable
- Git difftool does not work with `--check` HOT 1
- Git log doesn't apply set colors HOT 1
- E716: Key not present in Dictionary: "context" when executing Git difftool -y in bare repo HOT 2
- E716: Key not present in Dictionary: "-1" when running Git difftool -y in bare repo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-fugitive.