Config File Collection
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

zshrc 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. # ~/.zshrc file for zsh interactive shells.
  2. # see /usr/share/doc/zsh/examples/zshrc for examples
  3. # You should install some packages:
  4. # sudo apt install zsh zsh-syntax-highlighting zsh-autosuggestions qterminal fonts-firacode
  5. #
  6. setopt autocd # change directory just by typing its name
  7. #setopt correct # auto correct mistakes
  8. setopt interactivecomments # allow comments in interactive mode
  9. setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’
  10. setopt nonomatch # hide error message if there is no match for the pattern
  11. setopt notify # report the status of background jobs immediately
  12. setopt numericglobsort # sort filenames numerically when it makes sense
  13. setopt promptsubst # enable command substitution in prompt
  14. WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word
  15. # hide EOL sign ('%')
  16. PROMPT_EOL_MARK=""
  17. # configure key keybindings
  18. bindkey -e # emacs key bindings
  19. bindkey ' ' magic-space # do history expansion on space
  20. bindkey '^U' backward-kill-line # ctrl + U
  21. bindkey '^[[3;5~' kill-word # ctrl + Supr
  22. bindkey '^[[3~' delete-char # delete
  23. bindkey '^[[1;5C' forward-word # ctrl + ->
  24. bindkey '^[[1;5D' backward-word # ctrl + <-
  25. bindkey '^[[5~' beginning-of-buffer-or-history # page up
  26. bindkey '^[[6~' end-of-buffer-or-history # page down
  27. bindkey '^[[H' beginning-of-line # home
  28. bindkey '^[[F' end-of-line # end
  29. bindkey '^[[Z' undo # shift + tab undo last action
  30. # enable completion features
  31. autoload -Uz compinit
  32. compinit -d ~/.cache/zcompdump
  33. zstyle ':completion:*:*:*:*:*' menu select
  34. zstyle ':completion:*' auto-description 'specify: %d'
  35. zstyle ':completion:*' completer _expand _complete
  36. zstyle ':completion:*' format 'Completing %d'
  37. zstyle ':completion:*' group-name ''
  38. zstyle ':completion:*' list-colors ''
  39. zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
  40. #zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
  41. zstyle ':completion:*' rehash true
  42. zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
  43. zstyle ':completion:*' use-compctl false
  44. zstyle ':completion:*' verbose true
  45. zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
  46. # History configurations
  47. HISTFILE=~/.zsh_history
  48. HISTSIZE=1000
  49. SAVEHIST=2000
  50. setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
  51. setopt hist_ignore_dups # ignore duplicated commands history list
  52. setopt hist_ignore_space # ignore commands that start with space
  53. setopt hist_verify # show command with history expansion to user before running it
  54. #setopt share_history # share command history data
  55. # force zsh to show the complete history
  56. alias history="history 0"
  57. # configure `time` format
  58. TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P'
  59. # make less more friendly for non-text input files, see lesspipe(1)
  60. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  61. # set variable identifying the chroot you work in (used in the prompt below)
  62. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  63. debian_chroot=$(cat /etc/debian_chroot)
  64. fi
  65. # set a fancy prompt (non-color, unless we know we "want" color)
  66. case "$TERM" in
  67. xterm-color|*-256color) color_prompt=yes;;
  68. esac
  69. # uncomment for a colored prompt, if the terminal has the capability; turned
  70. # off by default to not distract the user: the focus in a terminal window
  71. # should be on the output of commands, not on the prompt
  72. force_color_prompt=yes
  73. if [ -n "$force_color_prompt" ]; then
  74. if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  75. # We have color support; assume it's compliant with Ecma-48
  76. # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  77. # a case would tend to support setf rather than setaf.)
  78. color_prompt=yes
  79. else
  80. color_prompt=
  81. fi
  82. fi
  83. configure_prompt() {
  84. prompt_symbol=㉿
  85. # Skull emoji for root terminal
  86. [ "$EUID" -eq 0 ] && prompt_symbol=💀
  87. case "$PROMPT_ALTERNATIVE" in
  88. twoline)
  89. PROMPT=$'%F{%(#.blue.green)}╔══${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.blue)}%n'$prompt_symbol$'%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n`giti -n`%F{%(#.blue.green)}╚═%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
  90. # Right-side prompt with exit codes and background processes
  91. RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'
  92. ;;
  93. oneline)
  94. PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{%(#.red.blue)}%n@%m%b%F{reset}:%B%F{%(#.blue.green)}%~%b%F{reset}%(#.#.$) '
  95. RPROMPT=
  96. ;;
  97. backtrack)
  98. PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{red}%n@%m%b%F{reset}:%B%F{blue}%~%b%F{reset}%(#.#.$) '
  99. RPROMPT=
  100. ;;
  101. esac
  102. unset prompt_symbol
  103. }
  104. # The following block is surrounded by two delimiters.
  105. # These delimiters must not be modified. Thanks.
  106. # START KALI CONFIG VARIABLES
  107. PROMPT_ALTERNATIVE=twoline
  108. NEWLINE_BEFORE_PROMPT=yes
  109. # STOP KALI CONFIG VARIABLES
  110. if [ "$color_prompt" = yes ]; then
  111. # override default virtualenv indicator in prompt
  112. VIRTUAL_ENV_DISABLE_PROMPT=1
  113. configure_prompt
  114. # enable syntax-highlighting
  115. if [ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
  116. . /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  117. ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
  118. ZSH_HIGHLIGHT_STYLES[default]=none
  119. ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=white,underline
  120. ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold
  121. ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
  122. ZSH_HIGHLIGHT_STYLES[global-alias]=fg=green,bold
  123. ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
  124. ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold
  125. ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline
  126. ZSH_HIGHLIGHT_STYLES[path]=bold
  127. ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
  128. ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
  129. ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold
  130. ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold
  131. ZSH_HIGHLIGHT_STYLES[command-substitution]=none
  132. ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta,bold
  133. ZSH_HIGHLIGHT_STYLES[process-substitution]=none
  134. ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta,bold
  135. ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=green
  136. ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=green
  137. ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
  138. ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold
  139. ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
  140. ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
  141. ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
  142. ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta
  143. ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta,bold
  144. ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta,bold
  145. ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta,bold
  146. ZSH_HIGHLIGHT_STYLES[assign]=none
  147. ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold
  148. ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
  149. ZSH_HIGHLIGHT_STYLES[named-fd]=none
  150. ZSH_HIGHLIGHT_STYLES[numeric-fd]=none
  151. ZSH_HIGHLIGHT_STYLES[arg0]=fg=cyan
  152. ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
  153. ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
  154. ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
  155. ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
  156. ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
  157. ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
  158. ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
  159. fi
  160. else
  161. PROMPT='${debian_chroot:+($debian_chroot)}%n@%m:%~%(#.#.$) '
  162. fi
  163. unset color_prompt force_color_prompt
  164. toggle_oneline_prompt(){
  165. if [ "$PROMPT_ALTERNATIVE" = oneline ]; then
  166. PROMPT_ALTERNATIVE=twoline
  167. else
  168. PROMPT_ALTERNATIVE=oneline
  169. fi
  170. configure_prompt
  171. zle reset-prompt
  172. }
  173. zle -N toggle_oneline_prompt
  174. bindkey ^P toggle_oneline_prompt
  175. # If this is an xterm set the title to user@host:dir
  176. case "$TERM" in
  177. xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty)
  178. TERM_TITLE=$'\e]0;${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%n@%m: %~\a'
  179. ;;
  180. *)
  181. ;;
  182. esac
  183. precmd() {
  184. # Print the previously configured title
  185. print -Pnr -- "$TERM_TITLE"
  186. # Print a new line before the prompt, but only if it is not the first line
  187. if [ "$NEWLINE_BEFORE_PROMPT" = yes ]; then
  188. if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then
  189. _NEW_LINE_BEFORE_PROMPT=1
  190. else
  191. print ""
  192. fi
  193. fi
  194. }
  195. # enable color support of ls, less and man, and also add handy aliases
  196. if [ -x /usr/bin/dircolors ]; then
  197. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  198. export LS_COLORS="$LS_COLORS:ow=30;44:" # fix ls color for folders with 777 permissions
  199. alias ls='ls --color=auto'
  200. #alias dir='dir --color=auto'
  201. #alias vdir='vdir --color=auto'
  202. alias grep='grep --color=auto'
  203. alias fgrep='fgrep --color=auto'
  204. alias egrep='egrep --color=auto'
  205. alias diff='diff --color=auto'
  206. alias ip='ip --color=auto'
  207. export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
  208. export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
  209. export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
  210. export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
  211. export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
  212. export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
  213. export LESS_TERMCAP_ue=$'\E[0m' # reset underline
  214. # Take advantage of $LS_COLORS for completion as well
  215. zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
  216. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
  217. fi
  218. # some more ls aliases
  219. alias ll='ls -l'
  220. alias la='ls -A'
  221. alias l='ls -CF'
  222. # enable auto-suggestions based on the history
  223. if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
  224. . /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  225. # change suggestion color
  226. ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
  227. fi
  228. if [ ! `which powerline-daemon` == "" ]; then
  229. powerline-daemon -q
  230. . /usr/share/powerline/bindings/zsh/powerline.zsh
  231. fi
  232. if [ ! `which neofetch` == "" ]; then
  233. neofetch
  234. fi
  235. # enable command-not-found if installed
  236. if [ -f /etc/zsh_command_not_found ]; then
  237. . /etc/zsh_command_not_found
  238. fi
  239. compinit