1
0

zshrc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. setopt EXTENDED_HISTORY # save historic timestamps!
  30. # random string function
  31. random-string()
  32. {
  33. LC_ALL=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1
  34. }
  35. # make code printable with pandocs
  36. # printable-code filename.ext [forced-extension]
  37. printable-code()
  38. {
  39. body=`cat ${1}`
  40. [[ ${1} =~ "([^.]+).([^.]+)" ]] && name=$match[1] && ext=$match[2]
  41. ext=`test -n "${2}" && echo ${2} || echo $ext`
  42. doc="# ${1}\n\`\`\`$ext\n$body\n\`\`\`"
  43. oformat=`test -n "${3}" && echo ${3} || echo "pdf"`
  44. echo $doc | pandoc -o "$name.$oformat"
  45. }
  46. # help creating links to emails
  47. # in apple mail, go to viewing → Show message headers → Custom... → Add "Message-ID"
  48. function murl () {
  49. echo message://"%3c"$@"%3e"
  50. }
  51. #
  52. # Aliases
  53. #
  54. # Git
  55. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  56. 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"
  57. alias imgcat="~/.dotfiles/imgcat"
  58. # Utility
  59. alias rm="nocorrect rm"
  60. #
  61. # Python
  62. #
  63. alias pip_update_all="pip install -r <(pip freeze | sed 's|==.*||') -U"
  64. #
  65. # direnv
  66. #
  67. eval "$(direnv hook zsh)"
  68. # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
  69. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
  70. # load homebrew autocompletions
  71. fpath=($(brew --prefix)/share/zsh/site-functions $fpath)
  72. zplug load
  73. # use up and down keys for substring search (needs to be called after plugin loading)
  74. bindkey '^[[A' history-substring-search-up
  75. bindkey '^[[B' history-substring-search-down
  76. [[ ! -f ~/.zsh_local_completions ]] || source ~/.zsh_local_completions
  77. # Better cp -- must go after compinit and stuff
  78. eval "$(zoxide init zsh)"