Advertisement
Guest User

Untitled

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