Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
116 lines (96 loc) · 3.57 KB
/
Copy pathmain.go
File metadata and controls
116 lines (96 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"fmt"
"os"
"runtime/debug"
"github.com/PatchMon/termd/internal/ui"
"github.com/PatchMon/termd/internal/version"
)
func main() {
debug.SetMemoryLimit(512 * 1024 * 1024)
args := os.Args[1:]
if len(args) > 0 {
switch args[0] {
case "-v", "--version", "version":
fmt.Print(version.Full())
if latest, available, err := version.CheckForUpdate(); err == nil {
if available {
fmt.Printf("\n Update available: %s -> %s\n", version.Version, latest)
fmt.Printf(" Run: %s\n", version.UpdateCommand())
} else if version.Version != "dev" {
fmt.Println("\n You're on the latest version.")
}
}
return
case "-h", "--help", "help":
printUsage()
return
}
}
if len(args) != 1 {
printUsage()
os.Exit(2)
}
path := args[0]
if err := ui.Run(path); err != nil {
fmt.Fprintf(os.Stderr, "termd: %v\n", err)
os.Exit(1)
}
}
func printUsage() {
fmt.Print(`termd — terminal markdown reader
Usage:
termd <file.md> Open markdown in a split-pane viewer
termd -v Version and update check
termd -h This help
Outline (left):
j / ↑ k / ↓ Move between headings
Enter Jump to selected section and focus document
g / G First / last section
Document (right):
Tab / Esc Switch between outline and document pane
PgUp / PgDn etc. Scroll the document (viewport keys)
Mouse wheel Scroll when the pointer is over the document
Shift + drag Select text (bypasses app mouse capture)
c Copy the visible code block to clipboard
o Open the visible image in your default viewer
Search:
/ Open the search bar (header)
Enter Confirm search and jump to first match
n / N Next / previous match
Esc Clear search and return to normal mode
Live Reload:
termd watches the file for changes and automatically reloads when saved.
Your scroll position is preserved across reloads.
Markdown support:
Tables Box-drawn, sized to content, GFM column alignment
Code blocks Framed and labelled, syntax highlighted via Chroma
Alerts > [!NOTE] [!TIP] [!IMPORTANT] [!WARNING] [!CAUTION]
Front matter Leading YAML is shown as a metadata header
Task lists - [x] / - [ ] render as ✓ / ○
Images:
Local images render inline in terminals speaking the kitty graphics
protocol — kitty, Ghostty, WezTerm and Konsole — where they scroll with
the document. Everywhere else images become a one-line callout; press o
to open the visible one in your system viewer. Remote images are never
fetched while rendering.
iTerm2 and sixel are implemented but off by default: they draw at the
cursor rather than into text cells, which shifts the text below them and
tears the image while scrolling. Opt in with TERMD_IMAGES=iterm2 if you
want them regardless.
Environment:
TERMD_THEME dark | light (default: detected)
TERMD_HYPERLINKS 1 | 0 (default: detected)
TERMD_IMAGES kitty | iterm2 | sixel | off (default: detected)
Set this over SSH, where the outer terminal's identity
does not reach the remote shell.
Install:
Linux, macOS, FreeBSD
curl -fsSL \
https://raw.githubusercontent.com/PatchMon/termd/main/install.sh | sh
Windows (PowerShell)
irm https://raw.githubusercontent.com/PatchMon/termd/main/install.ps1 | iex
Any platform with Go
go install github.com/PatchMon/termd@latest
`)
}