zshrc 2.8 KB

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