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.

216 lines
6.8 KiB

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