diff --git a/docs/commands/view.rst b/docs/commands/view.rst
index c8b4446..4e4670a 100644
--- a/docs/commands/view.rst
+++ b/docs/commands/view.rst
@@ -3,11 +3,15 @@ nnote view
.. code-block:: text
- nnote view
[-d ]
+ nnote view [-d ] [--pager]
Print the contents of a note to stdout.
+Use ``--pager`` to pipe the output through a pager (``$PAGER``, falling back
+to ``less``). Useful for long notes.
+
.. code-block:: bash
nnote view todo
nnote view standup -d work
+ nnote view meeting-notes --pager
diff --git a/nnote/commands/view.py b/nnote/commands/view.py
index ab7cc78..6f38a61 100644
--- a/nnote/commands/view.py
+++ b/nnote/commands/view.py
@@ -13,7 +13,13 @@
help="Subdirectory within notes dir",
shell_complete=complete_directories,
)
-def view(title, directory):
+@click.option(
+ "--pager",
+ is_flag=True,
+ default=False,
+ help="Pipe output through $PAGER (defaults to less)",
+)
+def view(title, directory, pager):
"""Print the contents of a note."""
config = Config.load()
note_path = resolve_note_path(config, title, directory)
@@ -21,4 +27,8 @@ def view(title, directory):
if not note_path.exists():
raise click.ClickException(f"Note not found: {note_path}")
- click.echo(note_path.read_text(encoding="utf-8"), nl=False)
+ content = note_path.read_text(encoding="utf-8")
+ if pager:
+ click.echo_via_pager(content)
+ else:
+ click.echo(content, nl=False)