1
0

zshrc 2.3 KB

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