1
0

zshrc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. # random string function
  18. random-string()
  19. {
  20. LC_ALL=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1
  21. }
  22. # make code printable with pandocs
  23. # printable-code filename.ext [forced-extension]
  24. printable-code()
  25. {
  26. body=`cat ${1}`
  27. [[ ${1} =~ "([^.]+).([^.]+)" ]] && name=$match[1] && ext=$match[2]
  28. ext=`test -n "${2}" && echo ${2} || echo $ext`
  29. doc="# ${1}\n\`\`\`$ext\n$body\n\`\`\`"
  30. oformat=`test -n "${3}" && echo ${3} || echo "pdf"`
  31. echo $doc | pandoc -o "$name.$oformat"
  32. }
  33. # help creating links to emails
  34. # in apple mail, go to viewing → Show message headers → Custom... → Add "Message-ID"
  35. function murl () {
  36. echo message://"%3c"$@"%3e"
  37. }
  38. #
  39. # Aliases
  40. #
  41. # Git
  42. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  43. 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"
  44. alias imgcat="~/.dotfiles/imgcat"
  45. # Utility
  46. alias rm="nocorrect rm"
  47. #
  48. # Python
  49. #
  50. alias pip_update_all="pip install -r <(pip freeze | sed 's|==.*||') -U"
  51. #
  52. # direnv
  53. #
  54. eval "$(direnv hook zsh)"
  55. # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
  56. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
  57. # load homebrew autocompletions
  58. fpath=($(brew --prefix)/share/zsh/site-functions $fpath)
  59. # zplug load
  60. if which sheldon > /dev/null; then
  61. eval "$(sheldon source)"
  62. fi
  63. zmodload zsh/complist
  64. zstyle ':completion:*' menu select
  65. # vi mode
  66. bindkey -v
  67. export KEYTIMEOUT=1
  68. # Use vim keys in tab complete menu:
  69. bindkey -M menuselect 'h' vi-backward-char
  70. bindkey -M menuselect 'k' vi-up-line-or-history
  71. bindkey -M menuselect 'l' vi-forward-char
  72. bindkey -M menuselect 'j' vi-down-line-or-history
  73. bindkey -v '^?' backward-delete-char
  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
  78. # Better cp -- must go after compinit and stuff
  79. eval "$(zoxide init zsh)"
  80. # Store if light or dark mode is active
  81. if [[ $(defaults read -g AppleInterfaceStyle 2&> /dev/null) == "Dark" ]]
  82. then
  83. UIMODE="dark"
  84. else
  85. UIMODE="light"
  86. fi
  87. export TASKRC=~/.taskrc-${UIMODE}