Guest User

Untitled

a guest
Mar 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. #!/bin/zsh
  2. over_ssh() {
  3. if [ -n "${SSH_CLIENT}" ]; then
  4. return 0
  5. else
  6. return 1
  7. fi
  8. }
  9.  
  10. if [[ ! -d "$HOME/.zsh" ]]; then
  11. mkdir -p "$HOME/.zsh"
  12. fi
  13. if [[ ! -d "$HOME/.cache" ]]; then
  14. mkdir -p "$HOME/.cache"
  15. fi
  16. zstyle ':completion:*' auto-description 'specify: %d'
  17. zstyle ':completion:*' completer _complete _match _approximate
  18. zstyle ':completion:*:match:*' original only
  19. zstyle ':completion:*:approximate:*' max-errors 1 numeric
  20. zstyle ':completion:*:functions' ignored-patterns '_*'
  21. zstyle ':completion:*' format 'Completing %d'
  22. zstyle ':completion:*' group-name ''
  23. zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
  24. zstyle ':completion:*' list-prompt '%S At %p: Hit TAB for more, or the character to insert %s'
  25. zstyle ':completion:*' matcher-list ''
  26. zstyle ':completion:*' menu select=1
  27. zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
  28. zstyle ':completion:*' verbose true
  29. zstyle ':completion:*' rehash true
  30. zstyle :compinstall filename "$HOME/.zshrc"
  31. zstyle ':completion:*' use-cache on
  32. zstyle ':completion:*' cache-path "$HOME/.cache/zsh"
  33.  
  34. autoload -Uz compinit
  35. autoload colors ; colors
  36. compinit
  37. setopt auto_cd
  38. setopt nobeep
  39. setopt PROMPT_SUBST
  40. setopt extendedGlob
  41.  
  42. # History
  43. HISTFILE="$HOME/.zsh/histfile"
  44. HISTSIZE=10000
  45. SAVEHIST=10000
  46. setopt completealiases
  47. setopt hist_ignore_dups
  48. setopt hist_ignore_space
  49. setopt interactivecomments
  50. setopt extended_history
  51. setopt append_history
  52. setopt inc_append_history
  53. setopt share_history
  54. if [[ ! -L "$HOME/.histfile" ]];then
  55. ln -sf "$HOME/.zsh/histfile" "$HOME/.histfile"
  56. fi
  57. # directory stack
  58. DIRSTACKSIZE=20
  59. DIRSTACKFILE="$HOME/.cache/dirstack"
  60. setopt autopushd pushdsilent pushdtohome
  61. setopt pushdignoredups
  62. setopt pushdminus
  63. if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
  64. dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
  65. [[ -d $dirstack[1] ]] && cd $dirstack[1]
  66. fi
  67.  
  68. # Shell correction
  69. setopt correct
  70.  
  71. #
  72. bindkey -e
  73. autoload -Uz promptinit
  74. promptinit
  75.  
  76. # Aliases
  77. case $OSTYPE in
  78. linux-gnu)
  79. alias grep='grep --color=auto'
  80. alias ls='ls --color=auto --human-readable --group-directories-first --classify --almost-all'
  81. ;;
  82. freebsd*)
  83. alias grep='grep --color=auto'
  84. alias ls='ls -FAGh'
  85. ;;
  86. openbsd*)
  87. alias ls='ls -FAh'
  88. ;;
  89. esac
  90.  
  91. # Prompt
  92. if over_ssh && [ -z "${TMUX}" ]; then
  93. prompt_is_ssh='%F{blue}[%F{red}SSH%F{blue}] '
  94. elif over_ssh; then
  95. prompt_is_ssh='%F{blue}[%F{253}SSH%F{blue}] '
  96. else
  97. unset prompt_is_ssh
  98. fi
  99. if [[ ${EUID} == 0 ]] ; then
  100. PROMPT="%F{red}%n%f@%F{cyan}%m%f ${prompt_is_ssh}%F{yellow}%1~%f %F{red}%# %F{white}"
  101. else
  102. PROMPT="%F{green}%n%f@%F{cyan}%m%f ${prompt_is_ssh}%F{yellow}%1~%f %F{green}%$$ %F{white}"
  103. fi
  104.  
  105. # Right Promt
  106. setopt prompt_subst
  107. autoload -Uz vcs_info
  108. zstyle ':vcs_info:*' actionformats \
  109. '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
  110. zstyle ':vcs_info:*' formats \
  111. '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
  112. zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
  113. zstyle ':vcs_info:*' enable git cvs svn
  114. vcs_info_wrapper() {
  115. vcs_info
  116. if [ -n "$vcs_info_msg_0_" ]; then
  117. echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
  118. fi
  119. }
  120. RPROMPT=$'$(vcs_info_wrapper)%F{yellow}[%F{white}%?%F{yellow}]%F{white}'
  121.  
  122. # Keybindings
  123. bindkey "${terminfo[khome]}" beginning-line
  124. bindkey "${terminfo[kend]}" end-of-line
  125. bindkey "\e[1~" beginning-of-line
  126. bindkey "\e[4~" end-of-line
  127. bindkey "\e[5~" beginning-of-history
  128. bindkey "\e[6~" end-of-history
  129. bindkey "\e[7~" beginning-of-line
  130. bindkey "\e[3~" delete-char
  131. bindkey "\e[2~" quoted-insert
  132. bindkey "\e[5C" forward-word
  133. bindkey "\e[5D" backward-word
  134. bindkey "\e\e[C" forward-word
  135. bindkey "\e\e[D" backward-word
  136. bindkey "\e[1;5C" forward-word
  137. bindkey "\e[1;5D" backward-word
  138. bindkey "\e[8~" end-of-line
  139. bindkey "\eOH" beginning-of-line
  140. bindkey "\eOF" end-of-line
  141. bindkey "\e[H" beginning-of-line
  142. bindkey "\e[F" end-of-line
  143.  
  144. # zsh syntax highlighting
  145. if [ -d /usr/share/zsh-syntax-highlighting ] ; then
  146. # Fedora, Debian
  147. source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  148. elif [ -d /usr/share/zsh/plugins/zsh-syntax-highlighting ] ; then
  149. # Arch-Linux
  150. source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  151. elif [ -d /usr/local/share/zsh-syntax-highlighting ] ; then
  152. # FreeBSD
  153. source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  154. fi
  155.  
  156. # Source modules
  157. if [ ! -d "$HOME/.zsh/modules" ] ; then
  158. mkdir -p "$HOME/.zsh/modules"
  159. fi
  160. to_source=($(find "$HOME/.zsh/modules" -name '*.zsh' -print | tr '\n' ' '))
  161. for module in ${to_source}; do
  162. source "$module"
  163. done
Add Comment
Please, Sign In to add comment