Files
iris-context/root/config_cmd.go
T
VERSE dd1fb156fc 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>
2026-08-09 21:08:11 +07:00

143 lines
3.1 KiB
Go

package root
import (
"fmt"
"os"
"path/filepath"
"github.com/BurntSushi/toml"
"github.com/spf13/cobra"
"github.com/versenilvis/iris/internal/config"
)
var ConfigCmd = &cobra.Command{
Use: "config",
Short: "manage iris configuration",
}
var ConfigInitCmd = &cobra.Command{
Use: "init",
Short: "initialize default configuration file with comments",
Run: func(cmd *cobra.Command, args []string) {
path, err := config.ConfigPath()
if err != nil {
fmt.Printf("failed to get config path: %v\n", err)
return
}
if _, statErr := os.Stat(path); statErr == nil {
fmt.Printf("config file already exists at %s\n", path)
return
}
_ = os.MkdirAll(filepath.Dir(path), 0755)
defaultContent := `# ~/.config/iris/config.toml
# iris configuration file
[core]
# schema version
# do not edit this field manually
version = 1
# override shell: "bash", "zsh", "fish", keep empty for auto detection
shell = ""
# run the selected shell as a login shell
shell-login = false
# startup mode: "last", "spec", "history"
# "last" = remember last mode used
mode = "last"
# enable debug logging
debug = false
# automatically expand aliases on space
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"
# enable Nerd Fonts icons in overlay menu
nerd-fonts = true
# show hidden files with dot prefix
hidden-files = false
# enable inline ghost text
ghost-text = true
# maximum suggestions to display
max-suggestions = 100
# maximum height of the overlay
max-height = 15
# maximum width of the overlay (0 = responsive to terminal)
max-width = 0
[git]
# hide current branch in checkout/switch list
filter-active-branch = true
# merge remote and local branches with same name
deduplicate-branches = true
[updater]
# check for updates on startup
check-on-startup = true
# update channel: "stable", "nightly"
channel = "stable"
# interval between update checks, e.g. "24h", "6h", "30m"
check-interval = "24h"
# 0 = off (default, notify only), 1 = auto-install, 2 = always confirm first
auto-update = 0
[keybindings]
toggle-mode = "ctrl+r"
toggle-menu = "shift+tab"
select = "tab"
navigate-up = "up"
navigate-down = "down"
navigate-right = "right"
`
err = os.WriteFile(path, []byte(defaultContent), 0644)
if err != nil {
fmt.Printf("failed to write config file: %v\n", err)
return
}
fmt.Printf("initialized config file at %s\n", path)
},
}
var ConfigShowCmd = &cobra.Command{
Use: "show",
Short: "show the resolved configuration",
Run: func(cmd *cobra.Command, args []string) {
enc := toml.NewEncoder(cmd.OutOrStdout())
if err := enc.Encode(config.Get()); err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "failed to encode config: %v\n", err)
}
},
}
func init() {
ConfigCmd.AddCommand(ConfigInitCmd)
ConfigCmd.AddCommand(ConfigShowCmd)
rootCmd.AddCommand(ConfigCmd)
}