feat(history): atuin history support (#134)
closes #91 3 mode config atuin history ```toml [core] # 0 = off, 1 = atuin history only, 2 = atuin history + default history atuin-history = 0 ``` Default is Mode 0 (turn off), who uses atuin history has to config it manually Mode 1 = atuin only (as you can see only 11 commands): <img width="1285" height="466" alt="image" src="https://github.com/user-attachments/assets/ca520ec7-fb45-4403-8087-a4951ba8dba0" /> Mode 2 = combine shell history + atuin history (prefer atuin): <img width="1261" height="469" alt="image" src="https://github.com/user-attachments/assets/1558ad3e-38f3-4d6e-bc8e-cfc00ea9cb4b" /> Mode 0 = turn off atuin --- Custom atuin db path if anyone's using their own path (leave empty to use default from atuin) ```toml atuin-db-path = "" ``` --- I also handled the search menu overlay of Atuin, IRIS won't show in this mode, but you have to change the keybind between 2 tool cuz they're using same keybind Ctrl + R, but I think using IRIS make it unnecessary to use Atuin search mode (82b180c9610f75d41008a54dfde474c7f2cce015) <img width="70%" alt="image" src="https://github.com/user-attachments/assets/e0c62050-7e6e-4e37-a1cc-2bfb63e1e984" /> <i><b>Before (Menu layout completely broken)</b></i> <img width="50%" alt="image" src="https://github.com/user-attachments/assets/1e6d8de9-cde8-473d-8a42-4748c480c812" /> <i ><b>After handling (not shows anymore)</b></i>
This commit is contained in:
@@ -59,6 +59,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"
|
||||
|
||||
+9
-3
@@ -55,11 +55,17 @@ func MergeResults(query string, mode string) []spec.Suggestion {
|
||||
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: "history",
|
||||
Icon: "history",
|
||||
Source: "history",
|
||||
Desc: h.Source,
|
||||
Icon: icon,
|
||||
Source: h.Source,
|
||||
Confidence: conf,
|
||||
})
|
||||
}
|
||||
|
||||
+15
-1
@@ -304,6 +304,7 @@ func runWrapper() {
|
||||
shellPGID = spec.ShellPID
|
||||
}
|
||||
var isCommandActive atomic.Bool
|
||||
var isAltScreenActive atomic.Bool
|
||||
var disableGhostText atomic.Bool
|
||||
disableGhostText.Store(!config.Get().UI.GhostText)
|
||||
var renderOverlayFn atomic.Value // holds func()
|
||||
@@ -315,6 +316,9 @@ func runWrapper() {
|
||||
}
|
||||
})
|
||||
isExecuting := func() bool {
|
||||
if isAltScreenActive.Load() {
|
||||
return true
|
||||
}
|
||||
if isCommandActive.Load() {
|
||||
// for bash: no preexec/precmd hooks, so fall back to TIOCGPGRP to detect when shell returns
|
||||
if shellName == "bash" {
|
||||
@@ -449,7 +453,17 @@ func runWrapper() {
|
||||
logger.Errorf("Unexpected PTY read error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
writeStdout(buf[:n])
|
||||
|
||||
// detect alternate screen buffer (smcup/rmcup) used by TUI apps (nvim, atuin, fzf)
|
||||
chunk := buf[:n]
|
||||
if bytes.Contains(chunk, []byte("\x1b[?1049h")) || bytes.Contains(chunk, []byte("\x1b[?1047h")) || bytes.Contains(chunk, []byte("\x1b[?47h")) {
|
||||
isAltScreenActive.Store(true)
|
||||
writeStdout([]byte(overlay.ClearAndDisable()))
|
||||
} else if bytes.Contains(chunk, []byte("\x1b[?1049l")) || bytes.Contains(chunk, []byte("\x1b[?1047l")) || bytes.Contains(chunk, []byte("\x1b[?47l")) {
|
||||
isAltScreenActive.Store(false)
|
||||
}
|
||||
|
||||
writeStdout(chunk)
|
||||
|
||||
bufferMu.Lock()
|
||||
nbEmpty := naiveBuffer == ""
|
||||
|
||||
Reference in New Issue
Block a user