Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/zsh
- over_ssh() {
- if [ -n "${SSH_CLIENT}" ]; then
- return 0
- else
- return 1
- fi
- }
- if [[ ! -d "$HOME/.zsh" ]]; then
- mkdir -p "$HOME/.zsh"
- fi
- if [[ ! -d "$HOME/.cache" ]]; then
- mkdir -p "$HOME/.cache"
- fi
- zstyle ':completion:*' auto-description 'specify: %d'
- zstyle ':completion:*' completer _complete _match _approximate
- zstyle ':completion:*:match:*' original only
- zstyle ':completion:*:approximate:*' max-errors 1 numeric
- zstyle ':completion:*:functions' ignored-patterns '_*'
- zstyle ':completion:*' format 'Completing %d'
- zstyle ':completion:*' group-name ''
- zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
- zstyle ':completion:*' list-prompt '%S At %p: Hit TAB for more, or the character to insert %s'
- zstyle ':completion:*' matcher-list ''
- zstyle ':completion:*' menu select=1
- zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
- zstyle ':completion:*' verbose true
- zstyle ':completion:*' rehash true
- zstyle :compinstall filename "$HOME/.zshrc"
- zstyle ':completion:*' use-cache on
- zstyle ':completion:*' cache-path "$HOME/.cache/zsh"
- autoload -Uz compinit
- autoload colors ; colors
- compinit
- setopt auto_cd
- setopt nobeep
- setopt PROMPT_SUBST
- setopt extendedGlob
- # History
- HISTFILE="$HOME/.zsh/histfile"
- HISTSIZE=10000
- SAVEHIST=10000
- setopt completealiases
- setopt hist_ignore_dups
- setopt hist_ignore_space
- setopt interactivecomments
- setopt extended_history
- setopt append_history
- setopt inc_append_history
- setopt share_history
- if [[ ! -L "$HOME/.histfile" ]];then
- ln -sf "$HOME/.zsh/histfile" "$HOME/.histfile"
- fi
- # directory stack
- DIRSTACKSIZE=20
- DIRSTACKFILE="$HOME/.cache/dirstack"
- setopt autopushd pushdsilent pushdtohome
- setopt pushdignoredups
- setopt pushdminus
- if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
- dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
- [[ -d $dirstack[1] ]] && cd $dirstack[1]
- fi
- # Shell correction
- setopt correct
- #
- bindkey -e
- autoload -Uz promptinit
- promptinit
- # Aliases
- case $OSTYPE in
- linux-gnu)
- alias grep='grep --color=auto'
- alias ls='ls --color=auto --human-readable --group-directories-first --classify --almost-all'
- ;;
- freebsd*)
- alias grep='grep --color=auto'
- alias ls='ls -FAGh'
- ;;
- openbsd*)
- alias ls='ls -FAh'
- ;;
- esac
- # Prompt
- if over_ssh && [ -z "${TMUX}" ]; then
- prompt_is_ssh='%F{blue}[%F{red}SSH%F{blue}] '
- elif over_ssh; then
- prompt_is_ssh='%F{blue}[%F{253}SSH%F{blue}] '
- else
- unset prompt_is_ssh
- fi
- if [[ ${EUID} == 0 ]] ; then
- PROMPT="%F{red}%n%f@%F{cyan}%m%f ${prompt_is_ssh}%F{yellow}%1~%f %F{red}%# %F{white}"
- else
- PROMPT="%F{green}%n%f@%F{cyan}%m%f ${prompt_is_ssh}%F{yellow}%1~%f %F{green}%$$ %F{white}"
- fi
- # Right Promt
- setopt prompt_subst
- autoload -Uz vcs_info
- zstyle ':vcs_info:*' actionformats \
- '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
- zstyle ':vcs_info:*' formats \
- '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
- zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
- zstyle ':vcs_info:*' enable git cvs svn
- vcs_info_wrapper() {
- vcs_info
- if [ -n "$vcs_info_msg_0_" ]; then
- echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
- fi
- }
- RPROMPT=$'$(vcs_info_wrapper)%F{yellow}[%F{white}%?%F{yellow}]%F{white}'
- # Keybindings
- bindkey "${terminfo[khome]}" beginning-line
- bindkey "${terminfo[kend]}" end-of-line
- bindkey "\e[1~" beginning-of-line
- bindkey "\e[4~" end-of-line
- bindkey "\e[5~" beginning-of-history
- bindkey "\e[6~" end-of-history
- bindkey "\e[7~" beginning-of-line
- bindkey "\e[3~" delete-char
- bindkey "\e[2~" quoted-insert
- bindkey "\e[5C" forward-word
- bindkey "\e[5D" backward-word
- bindkey "\e\e[C" forward-word
- bindkey "\e\e[D" backward-word
- bindkey "\e[1;5C" forward-word
- bindkey "\e[1;5D" backward-word
- bindkey "\e[8~" end-of-line
- bindkey "\eOH" beginning-of-line
- bindkey "\eOF" end-of-line
- bindkey "\e[H" beginning-of-line
- bindkey "\e[F" end-of-line
- # zsh syntax highlighting
- if [ -d /usr/share/zsh-syntax-highlighting ] ; then
- # Fedora, Debian
- source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
- elif [ -d /usr/share/zsh/plugins/zsh-syntax-highlighting ] ; then
- # Arch-Linux
- source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
- elif [ -d /usr/local/share/zsh-syntax-highlighting ] ; then
- # FreeBSD
- source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
- fi
- # Source modules
- if [ ! -d "$HOME/.zsh/modules" ] ; then
- mkdir -p "$HOME/.zsh/modules"
- fi
- to_source=($(find "$HOME/.zsh/modules" -name '*.zsh' -print | tr '\n' ' '))
- for module in ${to_source}; do
- source "$module"
- done
Add Comment
Please, Sign In to add comment