zshrc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Device-specifig setup (ignored by git)
  2. # source local config first to overwrite default theme if wanted
  3. source ~/.zsh_local
  4. # Source Prezto.
  5. if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  6. source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
  7. fi
  8. ### U S E R C O N F I G ###
  9. # random string function
  10. random-string()
  11. {
  12. LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1
  13. }
  14. # make code printable with pandocs
  15. # printable-code filename.ext [forced-extension]
  16. printable-code()
  17. {
  18. body=`cat ${1}`
  19. [[ ${1} =~ "([^.]+).([^.]+)" ]] && name=$match[1] && ext=$match[2]
  20. ext=`test -n "${2}" && echo ${2} || echo $ext`
  21. doc="# ${1}\n\`\`\`$ext\n$body\n\`\`\`"
  22. oformat=`test -n "${3}" && echo ${3} || echo "pdf"`
  23. echo $doc | pandoc -o "$name.$oformat"
  24. }
  25. # make the clipboard working on remote
  26. if [[ -n "$SSH_CLIENT" ]]; then
  27. SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
  28. alias pbcopy="ssh $SSH_IP pbcopy"
  29. fi
  30. #
  31. # Aliases
  32. #
  33. # Git
  34. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  35. 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"
  36. alias imgcat="~/.dotfiles/imgcat"
  37. # Utility
  38. alias rm="nocorrect rm"
  39. #
  40. # Python
  41. #
  42. # virtualenvwrapper
  43. source virtualenvwrapper.sh
  44. export VIRTUAL_ENV_DISABLE_PROMT=yes
  45. test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"