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.

210 lines
6.7 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 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.jaeschke-rogers@four.io"
  12. export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
  13. export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@four.io"
  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. # Disable the log builtin, so we don't conflict with /usr/bin/log
  19. disable log
  20. # Save command history
  21. HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
  22. HISTSIZE=99999999
  23. SAVEHIST=$HISTSIZE
  24. # Beep on error
  25. setopt BEEP
  26. # Use keycodes (generated via zkbd) if present, otherwise fallback on
  27. # values from terminfo
  28. if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
  29. source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
  30. else
  31. typeset -g -A key
  32. [[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
  33. [[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
  34. [[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
  35. [[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
  36. [[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
  37. [[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
  38. [[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
  39. [[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
  40. [[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
  41. [[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
  42. [[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
  43. [[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
  44. [[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
  45. [[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
  46. [[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
  47. [[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
  48. [[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
  49. [[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
  50. [[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
  51. [[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
  52. [[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
  53. [[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
  54. [[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
  55. [[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
  56. [[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
  57. [[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
  58. [[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
  59. [[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
  60. [[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
  61. [[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
  62. [[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
  63. fi
  64. # Default key bindings
  65. [[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
  66. [[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
  67. [[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
  68. [[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
  69. [[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
  70. # Default prompt
  71. #PS1="%n@%m %1~ %# "
  72. autoload -U colors && colors # Load colors
  73. PROMPT="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%1d%{$fg[red]%}]%{$reset_color%}$%b "
  74. setopt autocd # Automatically cd into typed directory.
  75. # Useful support for interacting with Terminal.app or other terminal programs
  76. [ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
  77. # Load aliases
  78. source ~/.config/aliasrc
  79. # Load Git completion
  80. zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
  81. fpath=(~/.zsh $fpath)
  82. autoload -Uz compinit && compinit
  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. cdv () {
  150. cd $(xclip -selection clipboard -o)
  151. }
  152. export PATH="/usr/local/opt/php@7.4/bin:$PATH"
  153. export PATH="/usr/local/opt/php@7.4/sbin:$PATH"
  154. # eval "$(starship init zsh)"
  155. export LESS='-R'
  156. export LESSOPEN='|~/.lessfilter %s'
  157. export QT_QPA_PLATFORMTHEME="qt5ct"
  158. # Open tmux when new interactive shell
  159. #if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then
  160. # exec tmux
  161. #fi
  162. export ANDROID_HOME=$HOME/Android/Sdk
  163. export PATH=$PATH:$ANDROID_HOME/platform-tools
  164. export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
  165. export ANDROID_SDK_ROOT='/opt/android-sdk'
  166. export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
  167. export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin/
  168. export PATH=$PATH:$ANDROID_ROOT/emulator
  169. export PATH=$PATH:$ANDROID_SDK_ROOT/tools/
  170. export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin