Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions rbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rbs
import (
"fmt"
"os/exec"
"regexp"
"strings"

"github.com/manifoldco/promptui"
Expand Down Expand Up @@ -58,6 +59,17 @@ func Run() {
searcher := func(input string, index int) bool {
branch := branches[index]
name := strings.Replace(strings.ToLower(branch.Name), " ", "", -1)
query := strings.Split(input, " ")

if query[0] == "$regex" && len(query) > 1 {
input = query[1]
reg, err := regexp.Compile(input)
if err != nil {
return false
}
return reg.MatchString(name)
}

input = strings.Replace(strings.ToLower(input), " ", "", -1)

return strings.Contains(name, input)
Expand Down