Add self-update, version 1.0.1

ghosttyconf --update installs the newest release from git.micw.org,
--check-update only checks. The download lands next to the running
binary, is started once with --version and only then replaces it.

Once a day a normal start asks in the background and mentions a newer
release in the header, at the top of the help and on stderr after
quitting; only on a terminal and not with GHOSTTYCONF_NO_UPDATE_CHECK
set. selfupdate.go is nscan's copyable template, with goca's --update
spelling in the hints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mikeandClaude Opus 5.5 committed 2026-10-28 10:22:51 +01:00
1 parent e5750ef24b
commit fb5602452a
13 files changed
+818 -11

No files matched your search

+5 -1
View File
@@ -99,6 +99,7 @@ type App struct {
quitAfterSave bool
autoReload bool
version string
update string // a newer release, if one is known
// Screen regions from the last render, for mouse handling.
catRect, optRect, docRect rect
@@ -159,6 +160,9 @@ func (a *App) SetAutoReload(on bool) { a.autoReload = on }
// SetVersion sets the program version shown in the help.
func (a *App) SetVersion(v string) { a.version = v }
// SetUpdate names a newer release, shown in the header and the help.
func (a *App) SetUpdate(v string) { a.update = v }
func (a *App) Init() tea.Cmd {
if a.gh == nil {
return nil
@@ -407,7 +411,7 @@ func (a *App) updateBrowse(km tea.KeyMsg) tea.Cmd {
case "q":
return a.quit()
case "?", "f1":
a.dlg = helpDialog(a.version)
a.dlg = helpDialog(a.version, a.update)
return nil
case "/", "ctrl+f":
// Every search starts fresh, like "/" in less or vim.