.zshrc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ################################################################################
  2. # Basic configuration
  3. ################################################################################
  4. setopt BEEP
  5. export TERM=alacritty
  6. export LANG=en_US.UTF-8
  7. # Disable the log builtin, so we don't conflict with /usr/bin/log
  8. disable log
  9. # Correctly display UTF-8 with combining characters.
  10. if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
  11. setopt COMBINING_CHARS
  12. fi
  13. ################################################################################
  14. # History
  15. ################################################################################
  16. HISTFILE=${ZDOTDIR}/.zsh_history
  17. HISTSIZE=2147483647
  18. SAVEHIST=$HISTSIZE
  19. export HISTORY_IGNORE="(ls|lsd|la|cd|pwd|exit)*"
  20. setopt HIST_EXPIRE_DUPS_FIRST
  21. setopt HIST_IGNORE_ALL_DUPS
  22. setopt HIST_IGNORE_DUPS
  23. setopt HIST_IGNORE_SPACE
  24. setopt HIST_REDUCE_BLANKS
  25. setopt HIST_VERIFY
  26. setopt INC_APPEND_HISTORY
  27. setopt SHARE_HISTORY
  28. ################################################################################
  29. # Prompt
  30. ################################################################################
  31. # A pleasant, informative, and transient prompt. Made possible by an arcane
  32. # incantation from [powerlevel10k](https://github.com/romkatv/powerlevel10k/),
  33. # as described in the project's issue tracker:
  34. # https://github.com/romkatv/powerlevel10k/issues/888#issuecomment-657969840
  35. autoload -Uz compinit
  36. compinit
  37. autoload -Uz vcs_info
  38. precmd_vcs_info() { vcs_info }
  39. setopt prompt_subst
  40. zstyle ':vcs_info:git:*' formats '%F{3}%F{8} %b '
  41. set-long-prompt() {
  42. if [ "$NEW_LINE_BEFORE_PROMPT" -eq 1 ]; then
  43. print ''
  44. else
  45. NEW_LINE_BEFORE_PROMPT=1
  46. fi
  47. PROMPT='%F{3}%F{8} %d %0(?..%F{3}%F{8} %? )${vcs_info_msg_0_}%F{3}󰒋%F{8} %m %F{3}%F{8} %n
  48. %F{3}$ %f%k'
  49. }
  50. set-short-prompt() {
  51. if [[ $PROMPT != '%F{3}$ %f%k' ]]; then
  52. PROMPT='%F{3}$ %f%k'
  53. zle .reset-prompt
  54. fi
  55. }
  56. precmd_functions=(
  57. set-long-prompt
  58. precmd_vcs_info
  59. )
  60. zle-line-finish() {
  61. set-short-prompt
  62. }
  63. zle -N zle-line-finish
  64. trap 'set-short-prompt; return 130' INT
  65. ################################################################################
  66. # Potentially interactive execution
  67. ################################################################################
  68. # Load SSH key into keychain
  69. if [[ $OSTYPE == darwin* ]] then
  70. ssh-add --apple-use-keychain $HOME/.ssh/id_rsa >/dev/null 2>&1
  71. else
  72. eval `keychain --eval --quiet id_rsa`
  73. fi
  74. ################################################################################
  75. # Aliases
  76. ################################################################################
  77. alias dockerprune="(docker system prune -a -f && docker system df -v) | less"
  78. ################################################################################
  79. # fzf
  80. ################################################################################
  81. if command -v fzf >> /dev/null; then
  82. eval "$(fzf --zsh)"
  83. fi
  84. ################################################################################
  85. # From github.com/zsh-users:
  86. # * zsh-autosuggestions
  87. # * zsh-syntax-highlighting
  88. # Both can be installed through Homebrew.
  89. ################################################################################
  90. if command -v brew >> /dev/null; then
  91. source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  92. source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  93. fi