1
0

zshrc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # use the symlinked ssh-auth-sock if available
  36. if [[ -f "$HOME/.ssh/ssh_auth_sock" ]]; then
  37. export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock;
  38. fi
  39. # make the clipboard working on remote
  40. if [[ -n "$SSH_CLIENT" ]]; then
  41. SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
  42. alias pbcopy="ssh $SSH_IP pbcopy"
  43. fi
  44. #
  45. # Aliases
  46. #
  47. # Git
  48. alias glol="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
  49. 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"
  50. alias imgcat="~/.dotfiles/imgcat"
  51. # Utility
  52. alias rm="nocorrect rm"
  53. #
  54. # Python
  55. #
  56. # virtualenvwrapper
  57. if [ -f ~/virtualenvwrapper.sh ]; then
  58. source ~/virtualenvwrapper.sh
  59. export VIRTUAL_ENV_DISABLE_PROMT=yes
  60. fi
  61. if [[ -n "$ITERM_INTEGRATION" && -f ~/.iterm2_shell_integration.zsh ]]; then
  62. test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
  63. fi