detached a703a07

refactor(dmenu): simplify history display to show URL without scheme

commit
a703a07d482677306da4d5b59890219fdbf126c8
author
bnema · · 2025-11-19 06:45 UTC
parent
760db44
signature
unsigned
1 file · +7 -38
M internal/cli/dmenu.go +7 -38
@@ -4,16 +4,16 @@ import (
44 "bufio"
55 "context"
66 "fmt"
7- "net/url"
87 "os"
98 "sort"
109 "strings"
1110 "time"
1211
12+ "github.com/spf13/cobra"
13+
1314 "github.com/bnema/dumber/internal/cache"
1415 "github.com/bnema/dumber/internal/config"
1516 "github.com/bnema/dumber/internal/services"
16- "github.com/spf13/cobra"
1717 )
1818
1919 const (
@@ -88,42 +88,11 @@ func generateOptions(cli *CLI) error {
8888 for _, match := range result.Matches {
8989 entry := match.Entry
9090
91- // Parse URL for domain extraction
92- parsedURL, err := url.Parse(entry.URL)
93- var domain string
94- if err != nil || parsedURL.Host == "" {
95- domain = "local"
96- } else {
97- domain = parsedURL.Host
98- }
99-
100- // Determine title
101- title := entry.Title
102- if title == "" || title == entry.URL {
103- // Use meaningful fallback for untitled pages
104- if parsedURL != nil && parsedURL.Path != "" && parsedURL.Path != "/" {
105- title = fmt.Sprintf("[%s%s]", domain, parsedURL.Path)
106- } else {
107- title = fmt.Sprintf("[%s]", domain)
108- }
109- }
110-
111- // Check if it's a Google search result and format accordingly
112- isGoogleSearch := domain == "www.google.com" && strings.Contains(entry.URL, "/search?q=")
113- if isGoogleSearch {
114- if parsedURL != nil {
115- if q := parsedURL.Query().Get("q"); q != "" {
116- title = fmt.Sprintf("Google: \"%s\"", q)
117- }
118- }
119- }
120-
121- // Format: "Title | domain.com | full-url"
122- // Using pipe separator for rofi/dmenu compatibility
123- display := fmt.Sprintf("%s | %s | %s",
124- truncateString(title, 50),
125- domain,
126- truncateString(entry.URL, 70))
91+ // Strip scheme from URL (remove https:// or http://)
92+ display := entry.URL
93+ display = strings.TrimPrefix(display, "https://")
94+ display = strings.TrimPrefix(display, "http://")
95+ display = truncateString(display, 100)
12796
12897 // Get favicon URL from cached entry
12998 faviconURL := match.Entry.FaviconURL
@@ -4,16 +4,16 @@ import (
4 "bufio"4 "bufio"
5 "context"5 "context"
6 "fmt"6 "fmt"
7- "net/url"
8 "os"7 "os"
9 "sort"8 "sort"
10 "strings"9 "strings"
11 "time"10 "time"
12 11
12+ "github.com/spf13/cobra"
13+
13 "github.com/bnema/dumber/internal/cache"14 "github.com/bnema/dumber/internal/cache"
14 "github.com/bnema/dumber/internal/config"15 "github.com/bnema/dumber/internal/config"
15 "github.com/bnema/dumber/internal/services"16 "github.com/bnema/dumber/internal/services"
16- "github.com/spf13/cobra"
17 )17 )
18 18
19 const (19 const (
@@ -88,42 +88,11 @@ func generateOptions(cli *CLI) error {
88 for _, match := range result.Matches {88 for _, match := range result.Matches {
89 entry := match.Entry89 entry := match.Entry
90 90
91- // Parse URL for domain extraction91+ // Strip scheme from URL (remove https:// or http://)
92- parsedURL, err := url.Parse(entry.URL)92+ display := entry.URL
93- var domain string93+ display = strings.TrimPrefix(display, "https://")
94- if err != nil || parsedURL.Host == "" {94+ display = strings.TrimPrefix(display, "http://")
95- domain = "local"95+ display = truncateString(display, 100)
96- } else {
97- domain = parsedURL.Host
98- }
99-
100- // Determine title
101- title := entry.Title
102- if title == "" || title == entry.URL {
103- // Use meaningful fallback for untitled pages
104- if parsedURL != nil && parsedURL.Path != "" && parsedURL.Path != "/" {
105- title = fmt.Sprintf("[%s%s]", domain, parsedURL.Path)
106- } else {
107- title = fmt.Sprintf("[%s]", domain)
108- }
109- }
110-
111- // Check if it's a Google search result and format accordingly
112- isGoogleSearch := domain == "www.google.com" && strings.Contains(entry.URL, "/search?q=")
113- if isGoogleSearch {
114- if parsedURL != nil {
115- if q := parsedURL.Query().Get("q"); q != "" {
116- title = fmt.Sprintf("Google: \"%s\"", q)
117- }
118- }
119- }
120-
121- // Format: "Title | domain.com | full-url"
122- // Using pipe separator for rofi/dmenu compatibility
123- display := fmt.Sprintf("%s | %s | %s",
124- truncateString(title, 50),
125- domain,
126- truncateString(entry.URL, 70))
127 96
128 // Get favicon URL from cached entry97 // Get favicon URL from cached entry
129 faviconURL := match.Entry.FaviconURL98 faviconURL := match.Entry.FaviconURL

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close