11 "github.com/charmbracelet/crush/internal/log"
14var getRg = sync.OnceValue(func() string {
15 path, err := exec.LookPath("rg")
17 if log.Initialized() {
18 slog.Warn("Ripgrep (rg) not found in $PATH. Some grep features might be limited or slower.")
25func getRgCmd(ctx context.Context, globPattern string) *exec.Cmd {
30 args := []string{"--files", "-L", "--null"}
31 if globPattern != "" {
32 if !filepath.IsAbs(globPattern) && !strings.HasPrefix(globPattern, "/") {
33 globPattern = "/" + globPattern
35 args = append(args, "--glob", globPattern)
37 return exec.CommandContext(ctx, name, args...)
40func getRgSearchCmd(ctx context.Context, pattern, path, include string) *exec.Cmd {
45 // Use -n to show line numbers, -0 for null separation to handle Windows paths
46 args := []string{"--json", "-H", "-n", "-0", pattern}
48 args = append(args, "--glob", include)
50 args = append(args, path)
52 return exec.CommandContext(ctx, name, args...)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list