atuin: Set up configuration

This commit is contained in:
Marty Oehme 2025-03-14 23:58:33 +01:00
parent 22af0cf46e
commit 71c5ac3f19
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 78 additions and 83 deletions
terminal
.config
.local/share/atuin

View file

@ -0,0 +1,75 @@
## which search mode to use
## possible values: prefix, fulltext, fuzzy, skim
# search_mode = "fuzzy"
## which filter mode to use
## possible values: global, host, session, directory
# filter_mode = "global"
# Enable 'workspace' filtering if we are in a git dir
workspaces = true
# don't always update timestamps etc
prefers_reduced_motion = true
# don't waste a line
show_tabs = false
# enter vi normal/insert mode automatically
keymap_mode = "auto"
## which filter mode to use when atuin is invoked from a shell up-key binding
## the accepted values are identical to those of "filter_mode"
## leave unspecified to use same mode set in "filter_mode"
filter_mode_shell_up_key_binding = "session"
## which search mode to use when atuin is invoked from a shell up-key binding
## the accepted values are identical to those of "search_mode"
## leave unspecified to use same mode set in "search_mode"
# search_mode_shell_up_key_binding = "fuzzy"
## which style to use
## possible values: auto, full, compact
style = "compact"
## prevent commands matching any of these regexes from being written to history.
## Note that these regular expressions are unanchored, i.e. if they don't start
## with ^ or end with $, they'll match anywhere in the command.
## For details on the supported regular expression syntax, see
## https://docs.rs/regex/latest/regex/#syntax
history_filter = [
"^pass"
# "^secret-cmd",
# "^innocuous-cmd .*--secret=.+"
]
## prevent commands run with cwd matching any of these regexes from being written
## to history. Note that these regular expressions are unanchored, i.e. if they don't
## start with ^ or end with $, they'll match anywhere in CWD.
## For details on the supported regular expression syntax, see
## https://docs.rs/regex/latest/regex/#syntax
# cwd_filter = [
# "^/very/secret/area"
# ]
## Configure whether or not to show the help row, which includes the current Atuin
## version (and whether an update is available), a keymap hint, and the total
## amount of commands in your history.
# show_help = true
enter_accept = true
#[stats]
# Set commands where we should consider the subcommand for statistics. Eg, kubectl get vs just kubectl
#common_subcommands = [
# "cargo",
# "go",
# "git",
# "npm",
# "yarn",
# "pnpm",
# "kubectl",
#]
#
# Set commands that should be totally stripped and ignored from stats
#common_prefix = ["sudo"]

View file

@ -25,7 +25,6 @@ if command -v zr >/dev/null 2>&1; then
molovo/tipz \
ael-code/zsh-colored-man-pages \
MichaelAquilina/zsh-auto-notify \
junegunn/fzf.git/shell/key-bindings.zsh \
Aloxaf/fzf-tab \
zdharma-continuum/fast-syntax-highlighting \
zsh-users/zsh-autosuggestions \
@ -35,7 +34,6 @@ if command -v zr >/dev/null 2>&1; then
else # or manually
[ -e /usr/share/oh-my-zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh ] && source /usr/share/oh-my-zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh
[ -e /usr/share/oh-my-zsh/plugins/command-not-found/command-not-found.plugin.zsh ] && source /usr/share/oh-my-zsh/plugins/command-not-found/command-not-found.plugin.zsh
[ -e /usr/share/fzf/key-bindings.zsh ] && source /usr/share/fzf/key-bindings.zsh
## find the correct installed tab-completion version
PLUG_FOLDER="/usr/share/zsh/plugins"
[ -e $PLUG_FOLDER/fzf-tab/fzf-tab.plugin.zsh ] && source $PLUG_FOLDER/fzf-tab/fzf-tab.plugin.zsh
@ -223,6 +221,9 @@ bindkey '^N' history-beginning-search-forward
# search history backwards <c-r>
bindkey '^o' history-incremental-search-backward
bindkey -M vicmd '^o' history-incremental-search-backward
bindkey '^r' atuin-search-viins
bindkey -M vicmd '^r' atuin-search-vicmd
# cycle through history results
bindkey -M isearch '^P' history-incremental-search-backward
bindkey -M isearch '^N' history-incremental-search-forward

View file

@ -1,81 +0,0 @@
# Source this in your ~/.config/nushell/config.nu
$env.ATUIN_SESSION = (atuin uuid)
# Magic token to make sure we don't record commands run by keybindings
let ATUIN_KEYBINDING_TOKEN = $"# (random uuid)"
let _atuin_pre_execution = {||
let cmd = (commandline)
if ($cmd | is-empty) {
return
}
if not ($cmd | str starts-with $ATUIN_KEYBINDING_TOKEN) {
$env.ATUIN_HISTORY_ID = (atuin history start -- $cmd)
}
}
let _atuin_pre_prompt = {||
let last_exit = $env.LAST_EXIT_CODE
if 'ATUIN_HISTORY_ID' not-in $env {
return
}
with-env { ATUIN_LOG: error } {
do { atuin history end $'--exit=($last_exit)' -- $env.ATUIN_HISTORY_ID | null } | null
}
hide-env ATUIN_HISTORY_ID
}
def _atuin_search_cmd [...flags: string] {
[
$ATUIN_KEYBINDING_TOKEN,
([
`commandline (ATUIN_LOG=error run-external --redirect-stderr atuin search`,
($flags | append [--interactive, --] | each {|e| $'"($e)"'}),
`(commandline) | complete | $in.stderr | str substring ..-1)`,
] | flatten | str join ' '),
] | str join "\n"
}
$env.config = ($env | default {} config).config
$env.config = ($env.config | default {} hooks)
$env.config = (
$env.config | upsert hooks (
$env.config.hooks
| upsert pre_execution (
$env.config.hooks | get -i pre_execution | default [] | append $_atuin_pre_execution)
| upsert pre_prompt (
$env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt)
)
)
$env.config = ($env.config | default [] keybindings)
$env.config = (
$env.config | upsert keybindings (
$env.config.keybindings
| append {
name: atuin
modifier: control
keycode: char_r
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd) }
}
)
)
# The up arrow keybinding has surprising behavior in Nu, and is disabled by default.
# See https://github.com/atuinsh/atuin/issues/1025 for details
# $env.config = (
# $env.config | upsert keybindings (
# $env.config.keybindings
# | append {
# name: atuin
# modifier: none
# keycode: up
# mode: [emacs, vi_normal, vi_insert]
# event: { send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding') }
# }
# )
# )