You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
5.8 KiB

4 years ago
  1. #!/bin/zsh
  2. # System-wide profile for interactive zsh(1) shells.
  3. # Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
  4. # and zshoptions(1) for more details.
  5. # set PATH so it includes user's private bin if it exists
  6. if [ -d "$HOME/.local/bin" ] ; then
  7. PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':')"
  8. fi
  9. # Correctly display UTF-8 with combining characters.
  10. if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
  11. setopt COMBINING_CHARS
  12. fi
  13. export HOMEBREW_NO_AUTO_UPDATE=1
  14. export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
  15. export GIT_AUTHOR_EMAIL="tovi.jaeschke-rogers@four.io"
  16. export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
  17. export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@four.io"
  18. export CASE_SENSITIVE="true"
  19. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
  20. export EDITOR=nvim
  21. export GIT_EDITOR=nvim
  22. # Disable the log builtin, so we don't conflict with /usr/bin/log
  23. disable log
  24. # Save command history
  25. HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
  26. HISTSIZE=99999999
  27. SAVEHIST=$HISTSIZE
  28. # Beep on error
  29. setopt BEEP
  30. # Use keycodes (generated via zkbd) if present, otherwise fallback on
  31. # values from terminfo
  32. if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
  33. source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
  34. else
  35. typeset -g -A key
  36. [[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
  37. [[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
  38. [[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
  39. [[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
  40. [[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
  41. [[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
  42. [[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
  43. [[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
  44. [[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
  45. [[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
  46. [[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
  47. [[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
  48. [[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
  49. [[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
  50. [[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
  51. [[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
  52. [[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
  53. [[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
  54. [[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
  55. [[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
  56. [[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
  57. [[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
  58. [[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
  59. [[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
  60. [[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
  61. [[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
  62. [[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
  63. [[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
  64. [[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
  65. [[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
  66. [[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
  67. fi
  68. # Default key bindings
  69. [[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
  70. [[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
  71. [[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
  72. [[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
  73. [[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
  74. # Default prompt
  75. #PS1="%n@%m %1~ %# "
  76. autoload -U colors && colors # Load colors
  77. PROMPT="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
  78. setopt autocd # Automatically cd into typed directory.
  79. # Useful support for interacting with Terminal.app or other terminal programs
  80. [ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
  81. # Load aliases
  82. source ~/.config/aliasrc
  83. # Load Git completion
  84. zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
  85. fpath=(~/.zsh $fpath)
  86. autoload -Uz compinit && compinit
  87. # Basic auto/tab complete:
  88. autoload -U compinit
  89. zstyle ':completion:*' menu select
  90. zmodload zsh/complist
  91. compinit
  92. _comp_options+=(globdots) # Include hidden files.
  93. # vi mode
  94. bindkey -v
  95. export KEYTIMEOUT=1
  96. # Use vim keys in tab complete menu:
  97. bindkey -M menuselect 'h' vi-backward-char
  98. bindkey -M menuselect 'k' vi-up-line-or-history
  99. bindkey -M menuselect 'l' vi-forward-char
  100. bindkey -M menuselect 'j' vi-down-line-or-history
  101. bindkey -v '^?' backward-delete-char
  102. # Change cursor shape for different vi modes.
  103. function zle-keymap-select {
  104. if [[ ${KEYMAP} == vicmd ]] ||
  105. [[ $1 = 'block' ]]; then
  106. echo -ne '\e[1 q'
  107. elif [[ ${KEYMAP} == main ]] ||
  108. [[ ${KEYMAP} == viins ]] ||
  109. [[ ${KEYMAP} = '' ]] ||
  110. [[ $1 = 'beam' ]]; then
  111. echo -ne '\e[5 q'
  112. fi
  113. }
  114. zle -N zle-keymap-select
  115. zle-line-init() {
  116. zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
  117. echo -ne "\e[5 q"
  118. }
  119. zle -N zle-line-init
  120. echo -ne '\e[5 q' # Use beam shape cursor on startup.
  121. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
  122. bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
  123. # Edit line in vim with ctrl-e:
  124. autoload edit-command-line; zle -N edit-command-line
  125. bindkey '^e' edit-command-line
  126. # Load syntax highlighting; should be last.
  127. source ~/.zsh/fsh/fast-syntax-highlighting.plugin.zsh 2>/dev/null
  128. source ~/.iterm2_shell_integration.zsh
  129. # Go up directory structures
  130. up() {
  131. cd $(printf "%0.0s../" $(seq 1 $1));
  132. }
  133. git-prune() {
  134. if [[ $@ == "--apply" ]]; then
  135. command git branch --merged develop | grep -vEw "develop$|master$" | xargs git branch -d
  136. else
  137. command git branch --merged develop | grep -vEw "develop$|master$"
  138. fi
  139. }
  140. export PATH="/usr/local/opt/php@7.4/bin:$PATH"
  141. export PATH="/usr/local/opt/php@7.4/sbin:$PATH"