zshrc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # instantaneously start tmux, if available
  2. if command -v tmux>/dev/null; then
  3. [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
  4. fi
  5. # Device-specifig setup (ignored by git)
  6. # source local config first to overwrite default theme if wanted
  7. source ~/.zsh_local
  8. # Source Prezto.
  9. if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  10. source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
  11. fi
  12. ### U S E R C O N F I G ###
  13. # random string function
  14. random-string()
  15. {
  16. LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1
  17. }
  18. # make code printable with pandocs
  19. # printable-code filename.ext [forced-extension]
  20. printable-code()
  21. {
  22. body=`cat ${1}`
  23. [[ ${1} =~ "([^.]+).([^.]+)" ]] && name=$match[1] && ext=$match[2]
  24. ext=`test -n "${2}" && echo ${2} || echo $ext`
  25. doc="# ${1}\n\`\`\`$ext\n$body\n\`\`\`"
  26. oformat=`test -n "${3}" && echo ${3} || echo "pdf"`
  27. echo $doc | pandoc -o "$name.$oformat"
  28. }
  29. # mount a remote host at /MountPoint/bla-home
  30. mounthome () {
  31. sshfs $1: /MountPoints/$1-home -o auto_cache,reconnect,volname=$1-home,no_readahead,noappledouble,nolocalcaches
  32. }
  33. # make the clipboard working on remote
  34. if [[ -n "$SSH_CLIENT" ]]; then
  35. SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
  36. alias pbcopy="ssh $SSH_IP pbcopy"
  37. fi
  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. # virtualenvwrapper
  51. if [ -f ~/virtualenvwrapper.sh ]; then
  52. source ~/virtualenvwrapper.sh
  53. export VIRTUAL_ENV_DISABLE_PROMT=yes
  54. fi
  55. if [ -f ~/.iterm2_shell_integration.zsh ]; then
  56. test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
  57. fi