program.go (1159B)
1 package tui 2 3 import ( 4 "git.prime8.dev/moncheeta/prime8dev/internal/vfs" 5 tea "github.com/charmbracelet/bubbletea" 6 "github.com/charmbracelet/lipgloss" 7 ssh "github.com/charmbracelet/ssh" 8 wish "github.com/charmbracelet/wish/bubbletea" 9 "github.com/muesli/termenv" 10 ) 11 12 func SSHHandler(sess ssh.Session) (tea.Model, []tea.ProgramOption) { 13 // TrueColor keeps the logo's 24-bit escapes intact. It does not touch the 14 // chrome: styles.go only uses the terminal default colors and ANSI 0-15, 15 // which every profile emits as plain SGR 30-37/90-97 so the terminal's 16 // own palette (light or dark) decides how they look. 17 lipgloss.SetColorProfile(termenv.TrueColor) 18 model := newPortfolioModel(defaultUser(sess.User())) 19 opts := wish.MakeOptions(sess) 20 opts = append(opts, tea.WithAltScreen()) 21 return model, opts 22 } 23 24 func (m portfolioModel) Init() tea.Cmd { 25 return tea.Batch( 26 bootTickCmd(), 27 tickCmd(), 28 cursorBlinkCmd(), 29 initWakaFooterCmd(), 30 ) 31 } 32 33 // defaultUser is the SSH session user as shown in prompts, whoami and the 34 // shell's home directory, sanitized to a safe path segment. 35 func defaultUser(user string) string { 36 return vfs.SanitizeUser(user) 37 }