package core import ( "os/exec" "regexp" "strings" "github.com/rivo/tview" ) var ( sh = regexp.MustCompile("\\{([^\\}]+)\\}") ) func Process(source string) string { source = sh.ReplaceAllStringFunc(source, func(match string) string { cmd := sh.FindStringSubmatch(match)[1] args := strings.Fields(cmd) shellArgs := []string{"-c", strings.Join(args, " ")} output, err := exec.Command("sh", shellArgs...).CombinedOutput() if err != nil { return err.Error() } return tview.TranslateANSI(strings.Trim(string(output), "\n")) }) return source }