diff --git a/complete.go b/complete.go index 56009fb..301b051 100644 --- a/complete.go +++ b/complete.go @@ -69,6 +69,8 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) { } } + completions = removeDupes(completions) + return completions, query } diff --git a/main.go b/main.go index af7f0b8..b20cdb7 100644 --- a/main.go +++ b/main.go @@ -268,3 +268,16 @@ func expandHome(path string) string { return strings.Replace(defaultHistDir, "~", homedir, 1) } + +func removeDupes(slice []string) []string { + all := make(map[string]bool) + newSlice := []string{} + for _, item := range slice { + if _, val := all[item]; !val { + all[item] = true + newSlice = append(newSlice, item) + } + } + + return newSlice +}