Skip to content

Instantly share code, notes, and snippets.

@ajkerrigan
Last active November 30, 2021 05:15
Show Gist options
  • Select an option

  • Save ajkerrigan/638d7f50bf6c74007095a582eef42f31 to your computer and use it in GitHub Desktop.

Select an option

Save ajkerrigan/638d7f50bf6c74007095a582eef42f31 to your computer and use it in GitHub Desktop.
Redirect print output from VisiData to vd.status
import contextlib
from io import StringIO
import visidata
from visidata import vd
class VDStatusIO(StringIO):
def write(self, s):
'''Forward writes to the VisiData message log'''
vd.status(s)
data = [{'x': 5, 'y': 10}]
# Launch a VisiData view whose writes to stdout (from e.g. print())
# get funneled to vd.status() instead.
with contextlib.redirect_stdout(VDStatusIO()):
visidata.pyobj.view(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment