That said, some form of advanced history search is a game changer, no matter how you get it. It's one of those "can't understand how I lived without it" things once you get it going.
That said, some form of advanced history search is a game changer, no matter how you get it. It's one of those "can't understand how I lived without it" things once you get it going.
If the command I want to match against is within the last few days or so, the fuzzy match performs ok, but anything from months ago which I know for a fact is in the history, it just doesn’t match it and instead shows irrelevant items (which technically I’m sure according to some algorithm are correct). Another one is I often have to put a ^ to ensure the ‘curl’ I’m searching for starts looking for matches at beginning of line.
Often times I still fall back to using fzf on ~/.zsh_history which seems to get what I want. There is this thread which is same issues I’m seeing, and I did try smart_sort=True but it’s still not great.
https://forum.atuin.sh/t/understanding-atuin-history-search/...
{ pkgs, ... }:
{
users.defaultUserShell = pkgs.zsh;
environment.systemPackages = with pkgs; [
atuin # ^R
eza # ls
git
zsh
];
programs.direnv.enable = true;
programs.nix-direnv.enable = true;
programs.zsh = {
enable = true;
enableCompletion = true;
enableBashCompletion = true;
enableGlobalCompInit = true;
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
syntaxHighlighting.enable = true;
syntaxHighlighting.highlighters = [ "main" "brackets" ];
# See `man zshoptions` for more details.
setOptions = [
# Remove duplicates continuously from command history (preserve newest entry).
"HIST_IGNORE_DUPS"
# Instantly share command history between all active shells.
"SHARE_HISTORY" # Alternative to: "APPEND_HISTORY", "INC_APPEND_HISTORY",
# Disable ^S and ^Z for less accidental freezing.
"FLOW_CONTROL"
# Save timestamp and duration of each command in command history.
"EXTENDED_HISTORY"
];
shellAliases = {
# Navigation
rm = "rm -iv";
ls = "eza -lg";
tree = "eza -lgT";
# git aliases
# ...
};
promptInit = ''
autoload -U promptinit
promptinit
prompt off
# Simple:
# PS1='[%n@%m:%~] %(!.#.$) '
# Colorful:
# PS1='[%F{green}%n@%m%f:%F{blue}%~%f] %(!.#.$) '
# Colorful with git branch:
function git_branch_name() {
branch=$(git symbolic-ref HEAD --short 2>/dev/null)
if [ ! -z "$branch" ]; then
echo -n " [%F{red}$branch%f]"
fi
}
# Omit username, print hostname + '$' with red when root, otherwise green:
prompt='[%(!.%F{red}.%F{green})%m%f:%F{blue}%~%f]$(git_branch_name) %(!.%F{red}#%f.$) '
# See: https://zsh.sourceforge.io/Doc/Release/Options.html#Prompting
setopt prompt_cr
setopt prompt_sp
setopt prompt_subst
export PROMPT_EOL_MARK=""
'';
interactiveShellInit = ''
# Prevent user-level "config missing" message.
touch $HOME/.zshrc
# MacOS
bindkey '^[[7~' beginning-of-line
bindkey '^[[8~' end-of-line
# Linux
bindkey '^[[1;3D' beginning-of-line # alt+left
bindkey '^[[1;3C' end-of-line # alt+right
bindkey '^[[1;5D' backward-word # ctrl+left
bindkey '^[[1;5C' forward-word # ctrl+right
# Both
bindkey '^R' history-incremental-search-backward
bindkey '^U' kill-whole-line
bindkey '^Y' yank
# My SSH endpoints don't recognize modern terminals
export TERM=xterm-256color
# ^R only
eval "$(atuin init zsh --disable-up-arrow)"
'';
};
}The chances of people reading this discussion running NixOS are small, and of those I'm sure the ones who were interested could search the internet for examples.
programs.atuin = {
enable = true;
enableZshIntegration = true;
};I just checked on their GitHub and it says "Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server."
So you trust all of your shell commands to be stored on a server that you don't control?
Maybe I'm missing something here.
*: nothing syncs if you don't register, and you can even compile a version with the sync code flagged out if you REALLY don't want to trust anything