msoe

Sample zshrc

Jan 14th, 2021
517
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion
  36.  
  37. # History configurations
  38. HISTFILE=~/.zsh_history
  39. HISTSIZE=1000
  40. SAVEHIST=2000
  41. setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
  42. setopt hist_ignore_dups       # ignore duplicated commands history list
  43. setopt hist_ignore_space      # ignore commands that start with space
  44. setopt hist_verify            # show command with history expansion to user before running it
  45. #setopt share_history         # share command history data
  46.  
  47. # force zsh to show the complete history
  48. alias history="history 0"
  49.  
  50. # make less more friendly for non-text input files, see lesspipe(1)
  51. #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  52.  
  53. # set variable identifying the chroot you work in (used in the prompt below)
  54. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  55.     debian_chroot=$(cat /etc/debian_chroot)
  56. fi
  57.  
  58. # set a fancy prompt (non-color, unless we know we "want" color)
  59. case "$TERM" in
  60.     xterm-color|*-256color) color_prompt=yes;;
  61. esac
  62.  
  63. # uncomment for a colored prompt, if the terminal has the capability; turned
  64. # off by default to not distract the user: the focus in a terminal window
  65. # should be on the output of commands, not on the prompt
  66. force_color_prompt=yes
  67.  
  68. if [ -n "$force_color_prompt" ]; then
  69.     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  70.     # We have color support; assume it's compliant with Ecma-48
  71.     # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
  72.     # a case would tend to support setf rather than setaf.)
  73.     color_prompt=yes
  74.     else
  75.     color_prompt=
  76.     fi
  77. fi
  78.  
  79. if [ "$color_prompt" = yes ]; then
  80.     PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)──}(%B%F{%(#.red.blue)}%n%(#.💀.㉿)%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} '
  81.     RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'
  82.  
  83.     # enable syntax-highlighting
  84.     if [ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && [ "$color_prompt" = yes ]; then
  85.     . /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  86.     ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
  87.     ZSH_HIGHLIGHT_STYLES[default]=none
  88.     ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold
  89.     ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold
  90.     ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
  91.     ZSH_HIGHLIGHT_STYLES[global-alias]=fg=magenta
  92.     ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
  93.     ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold
  94.     ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline
  95.     ZSH_HIGHLIGHT_STYLES[path]=underline
  96.     ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
  97.     ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
  98.     ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold
  99.     ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold
  100.     ZSH_HIGHLIGHT_STYLES[command-substitution]=none
  101.     ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta
  102.     ZSH_HIGHLIGHT_STYLES[process-substitution]=none
  103.     ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta
  104.     ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=magenta
  105.     ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=magenta
  106.     ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
  107.     ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold
  108.     ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
  109.     ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
  110.     ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
  111.     ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta
  112.     ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta
  113.     ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta
  114.     ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta
  115.     ZSH_HIGHLIGHT_STYLES[assign]=none
  116.     ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold
  117.     ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
  118.     ZSH_HIGHLIGHT_STYLES[named-fd]=none
  119.     ZSH_HIGHLIGHT_STYLES[numeric-fd]=none
  120.     ZSH_HIGHLIGHT_STYLES[arg0]=fg=green
  121.     ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
  122.     ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
  123.     ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
  124.     ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
  125.     ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
  126.     ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
  127.     ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
  128.     fi
  129. else
  130.     PROMPT='${debian_chroot:+($debian_chroot)}%n@%m:%~%# '
  131. fi
  132. unset color_prompt force_color_prompt
  133.  
  134. # If this is an xterm set the title to user@host:dir
  135. case "$TERM" in
  136. xterm*|rxvt*)
  137.     TERM_TITLE=$'\e]0;${debian_chroot:+($debian_chroot)}%n@%m: %~\a'
  138.     ;;
  139. *)
  140.     ;;
  141. esac
  142.  
  143. new_line_before_prompt=yes
  144. precmd() {
  145.     # Print the previously configured title
  146.     print -Pnr -- "$TERM_TITLE"
  147.  
  148.     # Print a new line before the prompt, but only if it is not the first line
  149.     if [ "$new_line_before_prompt" = yes ]; then
  150.     if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then
  151.         _NEW_LINE_BEFORE_PROMPT=1
  152.     else
  153.         print ""
  154.     fi
  155.     fi
  156. }
  157.  
  158. # enable color support of ls, less and man, and also add handy aliases
  159. if [ -x /usr/bin/dircolors ]; then
  160.     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  161.     alias ls='ls --color=auto'
  162.     #alias dir='dir --color=auto'
  163.     #alias vdir='vdir --color=auto'
  164.  
  165.     alias grep='grep --color=auto'
  166.     alias fgrep='fgrep --color=auto'
  167.     alias egrep='egrep --color=auto'
  168.     alias diff='diff --color=auto'
  169.     alias ip='ip --color=auto'
  170.  
  171.     export LESS_TERMCAP_mb=$'\E[1;31m'     # begin blink
  172.     export LESS_TERMCAP_md=$'\E[1;36m'     # begin bold
  173.     export LESS_TERMCAP_me=$'\E[0m'        # reset bold/blink
  174.     export LESS_TERMCAP_so=$'\E[01;33m'    # begin reverse video
  175.     export LESS_TERMCAP_se=$'\E[0m'        # reset reverse video
  176.     export LESS_TERMCAP_us=$'\E[1;32m'     # begin underline
  177.     export LESS_TERMCAP_ue=$'\E[0m'        # reset underline
  178.  
  179.     # Take advantage of $LS_COLORS for completion as well
  180.     zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
  181. fi
  182.  
  183. # some more ls aliases
  184. alias ll='ls -l'
  185. alias la='ls -A'
  186. alias l='ls -CF'
  187.  
  188. # enable auto-suggestions based on the history
  189. if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
  190.     . /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  191.     # change suggestion color
  192.     ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
  193. fi
  194.  
  195.  
RAW Paste Data