zshrc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #
  2. # Executes commands at the start of an interactive session.
  3. #
  4. # Authors:
  5. # Sorin Ionescu <sorin.ionescu@gmail.com>
  6. #
  7. source_if_exists() {
  8. [[ -f "$1" ]] && source "$1"
  9. }
  10. source_if_exists /etc/zsh/zshrc
  11. zsh_data_home="${XDG_DATA_HOME:-$HOME/.local/share}/zsh"
  12. if [[ -d "${zsh_data_home}/site-functions" ]]; then
  13. fpath=("${zsh_data_home}/site-functions" $fpath)
  14. typeset -gU fpath
  15. fi
  16. source_if_exists "${zsh_data_home}/zshrc.pre"
  17. source_if_exists "${zsh_data_home}/zsh.aliases"
  18. source_if_exists "${HOME}/.common_aliases"
  19. if [[ -z "$INSIDE_EMACS" ]]; then
  20. # Source Prezto.
  21. if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  22. source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
  23. fi
  24. else
  25. export PS1="%(?..[%?] )%n@%m:%1~> "
  26. fi
  27. source_if_exists "${zsh_data_home}/zshrc.post"
  28. # Customize to your needs...
  29. if (( $+commands[hstr] )); then
  30. # https://github.com/dvorka/hstr
  31. setopt histignorespace # skip cmds w/ leading space from history
  32. export HSTR_CONFIG=hicolor # get more colors
  33. bindkey -s "\C-r" "\C-a hstr -- \C-j" # bind hstr to Ctrl-r (for Vi mode check doc)
  34. fi
  35. if (( $+commands[aws_completer] )); then
  36. # https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html
  37. autoload bashcompinit && bashcompinit
  38. complete -C aws_completer aws # note: may slow down loading the shell
  39. fi
  40. if (( $+commands[direnv] )); then
  41. eval "$(direnv hook zsh)"
  42. fi
  43. autoload -Uz compinit && compinit
  44. # Fix keymap
  45. # commands in zle
  46. # or http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
  47. autoload zkbd
  48. source ${ZDOTDIR:-$HOME}/.zprezto/keymaps/xterm-256color-zkbd
  49. [[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
  50. [[ -n ${key[PageUp]} ]] && bindkey "${key[PageUp]}" up-line-or-history
  51. [[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
  52. [[ -n ${key[PageDown]} ]] && bindkey "${key[PageDown]}" down-line-or-history
  53. [[ -n ${key[CtrlRight]} ]] && bindkey "${key[CtrlRight]}" forward-word
  54. [[ -n ${key[CtrlLeft]} ]] && bindkey "${key[CtrlLeft]}" backward-word
  55. [[ -n ${key[Enter]} ]] && bindkey "${key[Enter]}" accept-line
  56. # Local Variables:
  57. # mode: sh
  58. # End: