Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.0 KiB

7 years ago
  1. # My zsh config file. One day, I will actually learn about zsh instead
  2. # of just haphazardly tossing crap at it.
  3. # Common path, aliases etc. for both shells I actually use:
  4. source ~/.sh_common
  5. autoload -U add-zsh-hook
  6. autoload -Uz compinit
  7. export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
  8. export HISTFILE=~/.histfile
  9. export HISTSIZE=15000
  10. export SAVEHIST=9999999
  11. setopt menu_complete
  12. setopt prompt_subst
  13. setopt inc_append_history
  14. setopt hist_ignore_space
  15. setopt hist_ignore_dups
  16. setopt autocd
  17. setopt extendedglob
  18. setopt autopushd pushdminus
  19. setopt printexitvalue
  20. unsetopt beep
  21. bindkey -e
  22. zstyle :compinstall filename '/home/brennen/.zshrc'
  23. compinit
  24. # https://wiki.archlinux.org/index.php/Zsh#History_search
  25. # Search up/down for matching thing on arrows - you can still use ctrl-n /
  26. # ctrl-p to move up and down in the overall command history:
  27. autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
  28. zle -N up-line-or-beginning-search
  29. zle -N down-line-or-beginning-search
  30. [[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-beginning-search
  31. [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-beginning-search
  32. # Grab some colors:
  33. autoload colors zsh/terminfo
  34. if [[ "$terminfo[colors]" -ge 8 ]]; then
  35. colors
  36. fi
  37. for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
  38. eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
  39. eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
  40. (( count = $count + 1 ))
  41. done
  42. PR_NO_COLOR="%{$terminfo[sgr0]%}"
  43. PR_SIGIL=\$
  44. PR_PATH_COLOR=$PR_BLUE;
  45. PR_TIME_COLOR=$PR_LIGHT_BLUE
  46. case "$HOST" in
  47. 'pisces')
  48. PR_HOST_COLOR=$PR_GREEN;
  49. ;;
  50. 'raspberrypi')
  51. PR_HOST_COLOR=$PR_MAGENTA;
  52. ;;
  53. 'catastrophe')
  54. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  55. ;;
  56. 'desiderata')
  57. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  58. PR_SIGIL=
  59. ;;
  60. 'exuberance')
  61. PR_HOST_COLOR=$PR_LIGHT_GREEN;
  62. # see bin/fragment-bullet:
  63. PR_SIGIL=
  64. ;;
  65. 'externality')
  66. PR_HOST_COLOR=$PR_LIGHT_GREEN;
  67. PR_SIGIL=
  68. ;;
  69. 'escalation')
  70. PR_HOST_COLOR=$PR_LIGHT_GREEN;
  71. PR_SIGIL=
  72. ;;
  73. 'fragility')
  74. PR_HOST_COLOR=$PR_WHITE;
  75. PR_SIGIL=
  76. ;;
  77. 'novena-edward-norway')
  78. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  79. PR_SIGIL=
  80. ;;
  81. 'errata')
  82. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  83. PR_SIGIL=
  84. ;;
  85. 'kropotkin')
  86. PR_HOST_COLOR=$PR_BLUE;
  87. ;;
  88. *)
  89. PR_HOST_COLOR=$PR_BLUE;
  90. ;;
  91. esac
  92. # Reset the prompt on every command to get that parse_git_branch
  93. # function to run. Might be a better way to do this, but whatever:
  94. function precmd {
  95. export PS1="$PR_HOST_COLOR%n@%m $PR_TIME_COLOR%* $PR_PATH_COLOR%d $(parse_git_branch)$PR_NO_COLOR$PR_SIGIL "
  96. }
  97. # Set up the prompt:
  98. export PS1="$PR_HOST_COLOR%n@%m $PR_TIME_COLOR%* $PR_PATH_COLOR%d $(parse_git_branch)$PR_NO_COLOR$PR_SIGIL "
  99. # Record directory history:
  100. function chpwd {
  101. echo $(pwd) >> ~/.directory_history
  102. }
  103. function bpb_preexec {
  104. # http://zsh.sourceforge.net/Doc/Release/Functions.html
  105. commandlog add "$@"
  106. }
  107. add-zsh-hook preexec bpb_preexec
  108. # fzf fuzzyfinder for use with Alt-c, Ctrl-r, Ctrl-t:
  109. [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh