zsh.nix 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. { pkgs, inputs, ... }:
  2. {
  3. programs.zsh = {
  4. enable = true;
  5. histFile = "~/.histfile";
  6. histSize = 10000;
  7. promptInit = "";
  8. setOptions = [
  9. "HIST_IGNORE_ALL_DUPS"
  10. "HIST_IGNORE_SPACE"
  11. "DOT_GLOB"
  12. "NO_HUP"
  13. "NO_CHECK_JOBS"
  14. ];
  15. interactiveShellInit = ''
  16. WORDCHARS+=$'|'
  17. ZLE_REMOVE_SUFFIX_CHARS=$' \t\n'
  18. PS1=$'%B%F{%(!.red.green)}%n@%m%f:%F{yellow}%~%f %2(L.^%L.)%#%b '
  19. precmd() {
  20. print -Pn '\e]133;A\e\\'
  21. print -Pn '\e]0;%n@%m: %~%2(L. ^%L.)\a'
  22. }
  23. stty -ixon -ixoff
  24. bindkey -e
  25. bindkey "''${terminfo[kbs]:-^?}" backward-delete-char
  26. bindkey "''${terminfo[kich1]:-^[[2~}" overwrite-mode
  27. bindkey "''${terminfo[kdch1]:-^[[3~}" delete-char
  28. bindkey "''${terminfo[khome]:-^[OH}" beginning-of-line
  29. bindkey "''${terminfo[kend]:-^[OF}" end-of-line
  30. bindkey "''${terminfo[kpp]:-^[[5~}" up-history
  31. bindkey "''${terminfo[knp]:-^[[6~}" down-history
  32. bindkey "''${terminfo[kcuu1]:-^[[A}" up-line-or-history
  33. bindkey "''${terminfo[kcud1]:-^[[B}" down-line-or-history
  34. bindkey "''${terminfo[kcuf1]:-^[[C}" forward-char
  35. bindkey "''${terminfo[kcub1]:-^[[D}" backward-char
  36. bindkey "''${terminfo[kUP5]:-^[[1;5A}" history-search-backward
  37. bindkey "''${terminfo[kDN5]:-^[[1;5B}" history-search-forward
  38. bindkey "''${terminfo[kRIT5]:-^[[1;5C}" forward-word
  39. bindkey "''${terminfo[kLFT5]:-^[[1;5D}" backward-word
  40. bindkey "''${terminfo[kcbt]:-^[[Z}" reverse-menu-complete
  41. if [[ -v terminfo[smkx] && -v terminfo[rmkx] ]]; then
  42. autoload -Uz add-zle-hook-widget
  43. function zle_application_mode_start { echoti smkx }
  44. function zle_application_mode_stop { echoti rmkx }
  45. add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
  46. add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
  47. fi
  48. zstyle ':completion:*' completer _expand _complete
  49. zstyle ':completion:*' menu select=2
  50. zstyle ':completion:*' rehash true
  51. zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS}
  52. zstyle ':completion:*' matcher-list ''' 'l:|=* r:|=*'
  53. source ${pkgs.fzf}/share/fzf/key-bindings.zsh
  54. hash -d nixpkgs=${inputs.nixpkgs}
  55. [[ -v TMUX ]] || ${pkgs.tmux}/bin/tmux ls 2>/dev/null
  56. '';
  57. shellInit = ''
  58. eval "''$(${pkgs.coreutils}/bin/dircolors -b)"
  59. [[ -s "/etc/profiles/per-user/''${USER}/etc/profile.d/hm-session-vars.sh" ]] && \
  60. source "/etc/profiles/per-user/''${USER}/etc/profile.d/hm-session-vars.sh"
  61. '';
  62. autosuggestions.enable = true;
  63. syntaxHighlighting.enable = true;
  64. };
  65. }