feat(history): add Atuin context scopes
This commit is contained in:
@@ -97,6 +97,10 @@ filter-active-branch = true
|
||||
# merge remote and local branches with same name
|
||||
deduplicate-branches = true
|
||||
|
||||
[history]
|
||||
# atuin scope for typed queries: "global", "directory", "workspace", or "hybrid"
|
||||
scope = "global"
|
||||
|
||||
[updater]
|
||||
# check for updates on startup
|
||||
check-on-startup = true
|
||||
|
||||
@@ -37,6 +37,9 @@ func TestConfigCommands(t *testing.T) {
|
||||
if !strings.Contains(string(content), "shell-login = false") {
|
||||
t.Error("expected initialized config to include shell-login = false")
|
||||
}
|
||||
if !strings.Contains(string(content), "scope = \"global\"") {
|
||||
t.Error("expected initialized config to include global history scope")
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
ConfigShowCmd.SetOut(buf)
|
||||
|
||||
@@ -247,6 +247,12 @@ expand-alias = true
|
||||
# automatically execute command after accepting suggestion
|
||||
auto-execute = false
|
||||
|
||||
# 0 = off, 1 = atuin history only, 2 = atuin history + default history
|
||||
atuin-history = 0
|
||||
|
||||
# custom atuin database path (leave empty for default)
|
||||
atuin-db-path = ""
|
||||
|
||||
[ui]
|
||||
# visual style: "modern" (icons, category pills, shortcut footer) or "classic" (minimalist, centered number, no icons)
|
||||
style = "modern"
|
||||
@@ -276,6 +282,10 @@ filter-active-branch = true
|
||||
# merge remote and local branches with same name
|
||||
deduplicate-branches = true
|
||||
|
||||
[history]
|
||||
# atuin scope for typed queries: "global", "directory", "workspace", or "hybrid"
|
||||
scope = "global"
|
||||
|
||||
[updater]
|
||||
# check for updates on startup
|
||||
check-on-startup = true
|
||||
|
||||
+4
-4
@@ -49,18 +49,18 @@ func MergeResults(query string, mode string) []spec.Suggestion {
|
||||
|
||||
if mode == "history" {
|
||||
aliases := spec.GetAliasesCopy()
|
||||
histResults, _ := integration.SearchHistory(query, aliases)
|
||||
histResults, _ := integration.SearchHistoryIn(query, aliases, spec.GetCWD())
|
||||
|
||||
// scale confidence based on recency (index in histResults) so the most recent commands stay on top
|
||||
baseConf := 75
|
||||
for i, h := range histResults {
|
||||
conf := max(baseConf-(i*2), 60)
|
||||
|
||||
|
||||
icon := "history"
|
||||
if h.Source == "atuin" {
|
||||
icon = "atuin"
|
||||
}
|
||||
|
||||
|
||||
addSuggestion(spec.Suggestion{
|
||||
Cmd: h.Cmd,
|
||||
Desc: h.Source,
|
||||
@@ -97,7 +97,7 @@ func MergeResults(query string, mode string) []spec.Suggestion {
|
||||
if len(tokens) > 0 {
|
||||
rootCmd = tokens[0]
|
||||
}
|
||||
|
||||
|
||||
ctxTimeout, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
|
||||
defer cancel()
|
||||
store, _ := scoring.GetFrecencyStore()
|
||||
|
||||
Reference in New Issue
Block a user