zshrc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # mount a remote host at /MountPoint/bla-home
  26. mounthome () {
  27. sshfs $1: /MountPoints/$1-home -o auto_cache,reconnect,volname=$1-home,no_readahead,noappledouble,nolocalcaches
  28. }
  29. # make the clipboard working on remote
  30. if [[ -n "$SSH_CLIENT" ]]; then
  31. SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
  32. alias pbcopy="ssh $SSH_IP pbcopy"
  33. fi
  34. #
  35. # Aliases
  36. #
  37. # Git
  38. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  39. 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"
  40. alias imgcat="~/.dotfiles/imgcat"
  41. # Utility
  42. alias rm="nocorrect rm"
  43. #
  44. # Python
  45. #
  46. # virtualenvwrapper
  47. if [ -f ~/virtualenvwrapper.sh ]; then
  48. source ~/virtualenvwrapper.sh
  49. export VIRTUAL_ENV_DISABLE_PROMT=yes
  50. fi
  51. test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"