.zshrc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # Enable colors and change prompt:
  2. autoload -U colors && colors
  3. PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
  4. # History in cache directory:
  5. HISTSIZE=10000
  6. SAVEHIST=10000
  7. HISTFILE=~/.cache/zsh/history
  8. # Basic auto/tab complete:
  9. autoload -U compinit
  10. zstyle ':completion:*' menu select
  11. zmodload zsh/complist
  12. compinit
  13. _comp_options+=(globdots) # Include hidden files.
  14. # vi mode
  15. bindkey -v
  16. export KEYTIMEOUT=1
  17. # Use vim keys in tab complete menu:
  18. bindkey -M menuselect 'h' vi-backward-char
  19. bindkey -M menuselect 'k' vi-up-line-or-history
  20. bindkey -M menuselect 'l' vi-forward-char
  21. bindkey -M menuselect 'j' vi-down-line-or-history
  22. bindkey -v '^?' backward-delete-char
  23. # Change cursor shape for different vi modes.
  24. function zle-keymap-select {
  25. if [[ ${KEYMAP} == vicmd ]] ||
  26. [[ $1 = 'block' ]]; then
  27. echo -ne '\e[1 q'
  28. elif [[ ${KEYMAP} == main ]] ||
  29. [[ ${KEYMAP} == viins ]] ||
  30. [[ ${KEYMAP} = '' ]] ||
  31. [[ $1 = 'beam' ]]; then
  32. echo -ne '\e[5 q'
  33. fi
  34. }
  35. zle -N zle-keymap-select
  36. zle-line-init() {
  37. zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
  38. echo -ne "\e[5 q"
  39. }
  40. zle -N zle-line-init
  41. echo -ne '\e[5 q' # Use beam shape cursor on startup.
  42. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
  43. # Use lf to switch directories and bind it to ctrl-o
  44. lfcd () {
  45. tmp="$(mktemp)"
  46. lf -last-dir-path="$tmp" "$@"
  47. if [ -f "$tmp" ]; then
  48. dir="$(cat "$tmp")"
  49. rm -f "$tmp"
  50. [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
  51. fi
  52. }
  53. bindkey -s '^o' 'lfcd\n'
  54. # Edit line in vim with ctrl-e:
  55. autoload edit-command-line; zle -N edit-command-line
  56. bindkey '^e' edit-command-line
  57. # Load aliases and shortcuts if existent.
  58. [ -f "$HOME/.config/exportrc" ] && source "$HOME/.config/exportrc"
  59. [ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
  60. if echo $USER | grep -q "miner"; then
  61. if cat /tmp/norisa/currently-mining | grep -q "0"; then
  62. echo "Start mining ..."
  63. echo "1" > /tmp/norisa/currently-mining
  64. nmine start
  65. fi
  66. fi
  67. # fish-like zsh autosuggestions
  68. source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
  69. # Load zsh-syntax-highlighting; should be last.
  70. source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null