1
0

zshrc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Device-specifig setup (ignored by git)
  2. # source local config first to overwrite default theme if wanted
  3. source ~/.zsh_local
  4. # start tmux in a nice way, if available
  5. t () {
  6. if command -v tmux>/dev/null; then
  7. [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && tmux new-session -A -s main
  8. fi
  9. }
  10. # Source Prezto.
  11. if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
  12. source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
  13. fi
  14. ### U S E R C O N F I G ###
  15. # random string function
  16. random-string()
  17. {
  18. LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-32} | head -n 1
  19. }
  20. # make code printable with pandocs
  21. # printable-code filename.ext [forced-extension]
  22. printable-code()
  23. {
  24. body=`cat ${1}`
  25. [[ ${1} =~ "([^.]+).([^.]+)" ]] && name=$match[1] && ext=$match[2]
  26. ext=`test -n "${2}" && echo ${2} || echo $ext`
  27. doc="# ${1}\n\`\`\`$ext\n$body\n\`\`\`"
  28. oformat=`test -n "${3}" && echo ${3} || echo "pdf"`
  29. echo $doc | pandoc -o "$name.$oformat"
  30. }
  31. # mount a remote host at /MountPoint/bla-home
  32. mounthome () {
  33. sshfs $1: /MountPoints/$1-home -o auto_cache,reconnect,volname=$1-home,no_readahead,noappledouble,nolocalcaches
  34. }
  35. # make the clipboard working on remote
  36. if [[ -n "$SSH_CLIENT" ]]; then
  37. SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
  38. alias pbcopy="ssh $SSH_IP pbcopy"
  39. fi
  40. #
  41. # Aliases
  42. #
  43. # Git
  44. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  45. 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"
  46. alias imgcat="~/.dotfiles/imgcat"
  47. # Utility
  48. alias rm="nocorrect rm"
  49. #
  50. # Python
  51. #
  52. # virtualenvwrapper
  53. if [ -f ~/virtualenvwrapper.sh ]; then
  54. source ~/virtualenvwrapper.sh
  55. export VIRTUAL_ENV_DISABLE_PROMT=yes
  56. fi
  57. if [[ -n "$ITERM_INTEGRATION" && -f ~/.iterm2_shell_integration.zsh ]]; then
  58. test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
  59. fi