.zshrc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. lfub -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. [ -f "$HOME/.config/norisa.local" ] && source "$HOME/.config/norisa.local"
  61. if echo $USER | grep -q "miner"; then
  62. if cat /tmp/norisa/currently-mining | grep -q "0"; then
  63. echo "Start mining ..."
  64. echo "1" > /tmp/norisa/currently-mining
  65. nmine start
  66. fi
  67. fi
  68. # This is the list for lf icons:
  69. export LF_ICONS="di=📁:\
  70. fi=📃:\
  71. tw=🤝:\
  72. ow=📂:\
  73. ln=⛓:\
  74. or=❌:\
  75. ex=🎯:\
  76. *.txt=✍:\
  77. *.mom=✍:\
  78. *.me=✍:\
  79. *.ms=✍:\
  80. *.png=🖼:\
  81. *.webp=🖼:\
  82. *.ico=🖼:\
  83. *.jpg=📸:\
  84. *.jpe=📸:\
  85. *.jpeg=📸:\
  86. *.gif=🖼:\
  87. *.svg=🗺:\
  88. *.tif=🖼:\
  89. *.tiff=🖼:\
  90. *.xcf=🖌:\
  91. *.html=🌎:\
  92. *.xml=📰:\
  93. *.gpg=🔒:\
  94. *.css=🎨:\
  95. *.pdf=📚:\
  96. *.djvu=📚:\
  97. *.epub=📚:\
  98. *.csv=📓:\
  99. *.xlsx=📓:\
  100. *.tex=📜:\
  101. *.md=📘:\
  102. *.r=📊:\
  103. *.R=📊:\
  104. *.rmd=📊:\
  105. *.Rmd=📊:\
  106. *.m=📊:\
  107. *.mp3=🎵:\
  108. *.opus=🎵:\
  109. *.ogg=🎵:\
  110. *.m4a=🎵:\
  111. *.flac=🎼:\
  112. *.wav=🎼:\
  113. *.mkv=🎥:\
  114. *.mp4=🎥:\
  115. *.webm=🎥:\
  116. *.mpeg=🎥:\
  117. *.avi=🎥:\
  118. *.mov=🎥:\
  119. *.mpg=🎥:\
  120. *.wmv=🎥:\
  121. *.m4b=🎥:\
  122. *.flv=🎥:\
  123. *.zip=📦:\
  124. *.rar=📦:\
  125. *.7z=📦:\
  126. *.tar.gz=📦:\
  127. *.z64=🎮:\
  128. *.v64=🎮:\
  129. *.n64=🎮:\
  130. *.gba=🎮:\
  131. *.nes=🎮:\
  132. *.gdi=🎮:\
  133. *.1=ℹ:\
  134. *.nfo=ℹ:\
  135. *.info=ℹ:\
  136. *.log=📙:\
  137. *.iso=📀:\
  138. *.img=📀:\
  139. *.bib=🎓:\
  140. *.ged=👪:\
  141. *.part=💔:\
  142. *.torrent=🔽:\
  143. *.jar=♨:\
  144. *.java=♨:\
  145. "
  146. # fish-like zsh autosuggestions
  147. source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
  148. # Load zsh-syntax-highlighting; should be last.
  149. source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null