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.

136 lines
3.2 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 HISTFILE=~/.histfile
  8. export HISTSIZE=15000
  9. export SAVEHIST=9999999
  10. setopt menu_complete
  11. setopt prompt_subst
  12. setopt inc_append_history
  13. setopt hist_ignore_space
  14. setopt hist_ignore_dups
  15. setopt autocd
  16. setopt extendedglob
  17. setopt autopushd pushdminus
  18. setopt printexitvalue
  19. unsetopt beep
  20. bindkey -e
  21. zstyle :compinstall filename '/home/brennen/.zshrc'
  22. compinit
  23. # https://wiki.archlinux.org/index.php/Zsh#History_search
  24. # Search up/down for matching thing on arrows - you can still use ctrl-n /
  25. # ctrl-p to move up and down in the overall command history:
  26. autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
  27. zle -N up-line-or-beginning-search
  28. zle -N down-line-or-beginning-search
  29. [[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-beginning-search
  30. [[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-beginning-search
  31. # prompt configuration {{{
  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. # Next, do per-host color and sigils.
  44. #
  45. # Great for sigils:
  46. # https://en.wikipedia.org/wiki/Unicode_Geometric_Shapes
  47. PR_SIGIL=\$
  48. PR_PATH_COLOR=$PR_BLUE;
  49. PR_TIME_COLOR=$PR_LIGHT_BLUE
  50. case "$HOST" in
  51. 'catastrophe')
  52. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  53. ;;
  54. 'desiderata')
  55. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  56. PR_SIGIL=
  57. ;;
  58. 'escalation')
  59. PR_HOST_COLOR=$PR_LIGHT_GREEN;
  60. PR_SIGIL=
  61. ;;
  62. 'errata')
  63. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  64. PR_SIGIL=
  65. ;;
  66. 'externality')
  67. PR_HOST_COLOR=$PR_LIGHT_GREEN;
  68. PR_SIGIL=
  69. ;;
  70. 'exuberance')
  71. PR_HOST_COLOR=$PR_LIGHT_GREEN;
  72. # see bin/fragment-bullet:
  73. PR_SIGIL=
  74. ;;
  75. 'fragility')
  76. PR_HOST_COLOR=$PR_WHITE;
  77. PR_SIGIL=
  78. ;;
  79. 'inertia')
  80. PR_HOST_COLOR=$PR_LIGHT_CYAN;
  81. PR_SIGIL=
  82. ;;
  83. 'novena-edward-norway')
  84. PR_HOST_COLOR=$PR_LIGHT_BLUE;
  85. PR_SIGIL=
  86. ;;
  87. 'pisces')
  88. PR_HOST_COLOR=$PR_GREEN;
  89. ;;
  90. 'raspberrypi')
  91. PR_HOST_COLOR=$PR_MAGENTA;
  92. ;;
  93. 'kropotkin')
  94. PR_HOST_COLOR=$PR_BLUE;
  95. ;;
  96. *)
  97. PR_HOST_COLOR=$PR_BLUE;
  98. ;;
  99. esac
  100. # Reset the prompt on every command to get that parse_git_branch
  101. # function to run. Might be a better way to do this, but whatever:
  102. function precmd {
  103. export PS1="$PR_HOST_COLOR%n@%m $PR_TIME_COLOR%* $PR_PATH_COLOR%d $(parse_git_branch)$PR_NO_COLOR$PR_SIGIL "
  104. }
  105. # Set up the prompt:
  106. export PS1="$PR_HOST_COLOR%n@%m $PR_TIME_COLOR%* $PR_PATH_COLOR%d $(parse_git_branch)$PR_NO_COLOR$PR_SIGIL "
  107. # }}}
  108. # Record directory history:
  109. function chpwd {
  110. echo $(pwd) >> ~/.directory_history
  111. }
  112. function bpb_preexec {
  113. # http://zsh.sourceforge.net/Doc/Release/Functions.html
  114. # Log the current command:
  115. commandlog add "$@"
  116. }
  117. add-zsh-hook preexec bpb_preexec
  118. # fzf fuzzyfinder for use with Alt-c, Ctrl-r, Ctrl-t:
  119. [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh