0
0

.zshrc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ################################################################################
  2. # ZSH Configuration
  3. #
  4. # Note: in order for files in ~/.config/ to be picked up, be sure to set the
  5. # global XDG_* and ZDOTDIR paths. On macOS, these is set at /etc/zshenv, and
  6. # look something like the following block:
  7. #
  8. # export XDG_CONFIG_HOME=$HOME/.config
  9. # export XDG_CACHE_HOME=$HOME/.cache
  10. # export XDG_DATA_HOME=$HOME/.local/share
  11. # export XDG_STATE_HOME=$HOME/.local/state
  12. # export XDG_RUNTIME_DIR=$HOME/.run
  13. # export XDG_DATA_DIRS=/usr/local/share:/usr/share
  14. # export XDG_CONFIG_DIRS=/etc/xdg
  15. # export ZDOTDIR=$XDG_CONFIG_HOME/zsh
  16. #
  17. ################################################################################
  18. ################################################################################
  19. # Basic configuration
  20. ################################################################################
  21. export TERM=alacritty
  22. export LANG=en_US.UTF-8
  23. export HISTSIZE=50000
  24. export SAVEHIST=50000
  25. export HISTORY_IGNORE="(ls|lsd|la|cd|pwd|exit)*"
  26. setopt INC_APPEND_HISTORY
  27. setopt HIST_IGNORE_ALL_DUPS
  28. setopt HIST_IGNORE_SPACE
  29. setopt HIST_REDUCE_BLANKS
  30. ################################################################################
  31. # Prompt
  32. ################################################################################
  33. # A pleasant, informative, and transient prompt. Made possible by an arcane
  34. # incantation from [powerlevel10k](https://github.com/romkatv/powerlevel10k/),
  35. # as described in the project's issue tracker:
  36. # https://github.com/romkatv/powerlevel10k/issues/888#issuecomment-657969840
  37. autoload -Uz compinit
  38. compinit
  39. autoload -Uz vcs_info
  40. precmd_vcs_info() { vcs_info }
  41. setopt prompt_subst
  42. zstyle ':vcs_info:git:*' formats '%F{3}%F{8} %b '
  43. set-long-prompt() {
  44. if [ "$NEW_LINE_BEFORE_PROMPT" -eq 1 ]; then
  45. print ''
  46. else
  47. NEW_LINE_BEFORE_PROMPT=1
  48. fi
  49. 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
  50. %F{3}$ %f%k'
  51. }
  52. set-short-prompt() {
  53. if [[ $PROMPT != '%F{3}$ %f%k' ]]; then
  54. PROMPT='%F{3}$ %f%k'
  55. zle .reset-prompt
  56. fi
  57. }
  58. precmd_functions=(
  59. set-long-prompt
  60. precmd_vcs_info
  61. )
  62. zle-line-finish() {
  63. set-short-prompt
  64. }
  65. zle -N zle-line-finish
  66. trap 'set-short-prompt; return 130' INT
  67. ################################################################################
  68. # Potentially interactive execution
  69. ################################################################################
  70. # Load SSH key into keychain
  71. if [[ $OSTYPE == darwin* ]] then
  72. ssh-add --apple-use-keychain ~/.ssh/id_rsa >/dev/null 2>&1
  73. else
  74. eval `keychain --eval --quiet id_rsa`
  75. fi
  76. ################################################################################
  77. # Aliases
  78. ################################################################################
  79. alias dockerprune="(docker system prune -a -f && docker system df -v) | less"
  80. ################################################################################
  81. # fzf
  82. ################################################################################
  83. if command -v fzf >> /dev/null; then
  84. eval "$(fzf --zsh)"
  85. fi
  86. ################################################################################
  87. # From github.com/zsh-users:
  88. # * zsh-autosuggestions
  89. # * zsh-syntax-highlighting
  90. # Both can be installed through Homebrew.
  91. ################################################################################
  92. if command -v brew >> /dev/null; then
  93. source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  94. source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  95. fi