1
0

zshrc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Device-specifig setup (ignored by git)
  2. # source local config first to overwrite default theme if wanted
  3. source ~/.zsh_local
  4. # activate plugin manager
  5. export ZPLUG_HOME=$HOME/.dotfiles/external/zplug
  6. source $ZPLUG_HOME/init.zsh
  7. zplug "romkatv/powerlevel10k", as:theme, use:"*10k.zsh-theme", depth:1
  8. zplug "zsh-users/zsh-syntax-highlighting", defer:2
  9. zplug "zsh-users/zsh-history-substring-search", defer:3
  10. zplug "junegunn/fzf", use:"shell/*.zsh"
  11. zplug "modules/git", from:prezto
  12. zplug "modules/completion", from:prezto
  13. zplug "docker/compose", use:contrib/completion/zsh
  14. zplug "docker/cli", use:contrib/completion/zsh
  15. zplug "Azure/azure-cli", use:az.completion, defer:3
  16. ### U S E R C O N F I G ###
  17. zmodload zsh/complist
  18. zstyle ':completion:*' menu select
  19. # vi mode
  20. bindkey -v
  21. export KEYTIMEOUT=1
  22. # Use vim keys in tab complete menu:
  23. bindkey -M menuselect 'h' vi-backward-char
  24. bindkey -M menuselect 'k' vi-up-line-or-history
  25. bindkey -M menuselect 'l' vi-forward-char
  26. bindkey -M menuselect 'j' vi-down-line-or-history
  27. bindkey -v '^?' backward-delete-char
  28. # random string function
  29. random-string()
  30. {
  31. LC_ALL=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1
  32. }
  33. # make code printable with pandocs
  34. # printable-code filename.ext [forced-extension]
  35. printable-code()
  36. {
  37. body=`cat ${1}`
  38. [[ ${1} =~ "([^.]+).([^.]+)" ]] && name=$match[1] && ext=$match[2]
  39. ext=`test -n "${2}" && echo ${2} || echo $ext`
  40. doc="# ${1}\n\`\`\`$ext\n$body\n\`\`\`"
  41. oformat=`test -n "${3}" && echo ${3} || echo "pdf"`
  42. echo $doc | pandoc -o "$name.$oformat"
  43. }
  44. # help creating links to emails
  45. # in apple mail, go to viewing → Show message headers → Custom... → Add "Message-ID"
  46. function murl () {
  47. echo message://"%3c"$@"%3e"
  48. }
  49. #
  50. # Aliases
  51. #
  52. # Git
  53. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  54. alias glola="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
  55. alias imgcat="~/.dotfiles/imgcat"
  56. # Utility
  57. alias rm="nocorrect rm"
  58. #
  59. # Python
  60. #
  61. alias pip_update_all="pip install -r <(pip freeze | sed 's|==.*||') -U"
  62. #
  63. # direnv
  64. #
  65. eval "$(direnv hook zsh)"
  66. # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
  67. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
  68. # load homebrew autocompletions
  69. fpath=($(brew --prefix)/share/zsh/site-functions $fpath)
  70. zplug load
  71. # use up and down keys for substring search (needs to be called after plugin loading)
  72. bindkey '^[[A' history-substring-search-up
  73. bindkey '^[[B' history-substring-search-down
  74. [[ ! -f ~/.zsh_local_completions ]] || source ~/.zsh_local_completions