5 ms·
If using Nix, you can get Atuin working basically for free by just enabling it in the config. I love it. Does everything I'd every hoped for with history search
by colordrops 2y ago
If using Nix, you can get Atuin working basically for free by just enabling it in the config. I love it. Does everything I'd every hoped for with history search.
- sshine 2y agoI'm also in this boat. I have atuin as part of my zsh config that is distributed to all new machines, whether they run NixOS or some other operating system with Nix on them (e.g. MacOS). After switching to NixOS I found an interest in maintaining a custom setup again, since it wouldn't fall apart every time I moved machine. { 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)" ''; }; }
- stevekemp 2y agoDid you really need to share 108 lines of code, inline, rather than a link to gist/similar? 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.
- Diti 2y agoNixOS and Kagi user here. Hacker News often is the most reliable search result there is. Gists aren’t (they become easily deleted, unlike HN comments).
- stevekemp 2y agoSure, and I accept that happily enough for "small" snippets. But I had to page down multiple times and it really felt like too much content.
- sshine 2y agoI could have cut down the sample a lot, I apologize.
- colordrops 2y agoOr if using home manager: programs.atuin = { enable = true; enableZshIntegration = true; };
- EasyMark 2y agoI don't really like nix (yeah I tried it for a couple of months), but I'd like to point out that atuin is exceptionally easy to set up even without using nix as well in case someone gets an idea that it is difficult.