1
0

zshrc 2.8 KB

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