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.

227 lines
7.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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. # Correctly display UTF-8 with combining characters.
  6. if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
  7. setopt COMBINING_CHARS
  8. fi
  9. export HOMEBREW_NO_AUTO_UPDATE=1
  10. export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
  11. export GIT_AUTHOR_EMAIL="tovi@tovijaeschke.xyz"
  12. export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
  13. export GIT_COMMITTER_EMAIL="tovi@tovijaeschke.xyz"
  14. export CASE_SENSITIVE="true"
  15. zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
  16. export EDITOR=nvim
  17. export GIT_EDITOR=nvim
  18. export BROWSER=chromium
  19. # Disable the log builtin, so we don't conflict with /usr/bin/log
  20. disable log
  21. # Save command history
  22. HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
  23. HISTSIZE=99999999
  24. SAVEHIST=$HISTSIZE
  25. # Beep on error
  26. setopt BEEP
  27. export PATH="~/.local/bin/:$PATH"
  28. export PATH="~/dotfiles/.local/bin/:$PATH"
  29. # Use keycodes (generated via zkbd) if present, otherwise fallback on
  30. # values from terminfo
  31. if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
  32. source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
  33. else
  34. typeset -g -A key
  35. [[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
  36. [[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
  37. [[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
  38. [[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
  39. [[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
  40. [[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
  41. [[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
  42. [[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
  43. [[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
  44. [[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
  45. [[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
  46. [[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
  47. [[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
  48. [[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
  49. [[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
  50. [[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
  51. [[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
  52. [[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
  53. [[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
  54. [[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
  55. [[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
  56. [[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
  57. [[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
  58. [[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
  59. [[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
  60. [[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
  61. [[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
  62. [[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
  63. [[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
  64. [[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
  65. [[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
  66. fi
  67. # Default key bindings
  68. [[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
  69. [[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
  70. [[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
  71. [[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
  72. [[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
  73. autoload -U colors && colors # Load colors
  74. PROMPT="%{$fg[blue]%}%1~ %{$fg[green]%}>%{$reset_color%} "
  75. setopt autocd # Automatically cd into typed directory.
  76. # Useful support for interacting with Terminal.app or other terminal programs
  77. [ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
  78. # Load aliases
  79. source ~/.config/aliasrc
  80. # Load Git completion
  81. zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
  82. fpath=(~/.zsh $fpath)
  83. # Basic auto/tab complete:
  84. autoload -U compinit
  85. zstyle ':completion:*' menu select
  86. zmodload zsh/complist
  87. compinit
  88. _comp_options+=(globdots) # Include hidden files.
  89. # vi mode
  90. bindkey -v
  91. export KEYTIMEOUT=1
  92. # Use vim keys in tab complete menu:
  93. bindkey -M menuselect 'h' vi-backward-char
  94. bindkey -M menuselect 'k' vi-up-line-or-history
  95. bindkey -M menuselect 'l' vi-forward-char
  96. bindkey -M menuselect 'j' vi-down-line-or-history
  97. bindkey -v '^?' backward-delete-char
  98. # Change cursor shape for different vi modes.
  99. function zle-keymap-select {
  100. if [[ ${KEYMAP} == vicmd ]] ||
  101. [[ $1 = 'block' ]]; then
  102. echo -ne '\e[1 q'
  103. elif [[ ${KEYMAP} == main ]] ||
  104. [[ ${KEYMAP} == viins ]] ||
  105. [[ ${KEYMAP} = '' ]] ||
  106. [[ $1 = 'beam' ]]; then
  107. echo -ne '\e[5 q'
  108. fi
  109. }
  110. zle -N zle-keymap-select
  111. zle-line-init() {
  112. zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
  113. echo -ne "\e[5 q"
  114. }
  115. zle -N zle-line-init
  116. echo -ne '\e[5 q' # Use beam shape cursor on startup.
  117. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
  118. bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
  119. # Edit line in vim with ctrl-e:
  120. autoload edit-command-line; zle -N edit-command-line
  121. bindkey '^e' edit-command-line
  122. # Load syntax highlighting; should be last.
  123. source ~/.zsh/fsh/fast-syntax-highlighting.plugin.zsh 2>/dev/null
  124. # Go up directory structures
  125. up () {
  126. cd $(printf "%0.0s../" $(seq 1 $1));
  127. }
  128. git-prune () {
  129. if [[ $@ == "--apply" ]]; then
  130. command git branch --merged develop | grep -vEw "develop$|master$" | xargs git branch -d
  131. else
  132. command git branch --merged develop | grep -vEw "develop$|master$"
  133. fi
  134. }
  135. mkcd () {
  136. mkdir -p $@ && cd $@
  137. }
  138. # Use lf to switch directories and bind it to ctrl-o
  139. lfcd () {
  140. tmp="$(mktemp)"
  141. lfpreview -last-dir-path="$tmp" "$@"
  142. if [ -f "$tmp" ]; then
  143. dir="$(cat "$tmp")"
  144. rm -f "$tmp" >/dev/null
  145. [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
  146. fi
  147. }
  148. bindkey -s '^o' 'lfcd\n'
  149. function cdv () {
  150. if [[ $(uname) == 'Darwin' ]]; then
  151. cd $(pbpaste)
  152. return
  153. fi
  154. cd $(xclip -selection clipboard -o)
  155. }
  156. function cdf () {
  157. cd $(find . -type d -print | fzf)
  158. }
  159. export PATH="/usr/local/opt/php@7.4/bin:$PATH"
  160. export PATH="/usr/local/opt/php@7.4/sbin:$PATH"
  161. if [[ $(uname) == 'Darwin' ]]; then
  162. export PATH="/opt/homebrew/lib/ruby/gems/3.3.0:$PATH"
  163. export PATH="/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0:$PATH"
  164. fi
  165. export LESS='-R'
  166. export LESSOPEN='|~/.lessfilter %s'
  167. export ANDROID_HOME=$HOME/Android/Sdk
  168. if [[ $(uname) == 'Darwin' ]]; then
  169. export ANDROID_HOME=$HOME/Library/Android/sdk
  170. export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
  171. fi
  172. export PATH=$PATH:$ANDROID_HOME/platform-tools
  173. export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
  174. export PATH="/run/user/1000/fnm_multishells/20590_1663546026606/bin":$PATH
  175. export FNM_MULTISHELL_PATH="/run/user/1000/fnm_multishells/20590_1663546026606"
  176. export FNM_VERSION_FILE_STRATEGY="local"
  177. export FNM_DIR="/home/tovi/.local/share/fnm"
  178. export FNM_LOGLEVEL="info"
  179. export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist"
  180. export FNM_ARCH="x64"
  181. rehash
  182. export PHPCS_STANDARD=~/.config/phpcs.xml
  183. if [[ $(uname) == 'Darwin' ]]; then
  184. eval "$(rbenv init - zsh)"
  185. fi