.zshrc 5.3 KB
Newer Older
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
1 2 3 4 5 6 7 8 9
# The following lines were added by compinstall

zstyle ':completion:*' completer _expand _complete _ignored
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' matcher-list '' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle ':completion:*' squeeze-slashes true
zstyle :compinstall filename '/home/bro3886/.zshrc'

autoload -Uz compinit
10
compinit -i
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
11 12 13
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
Murukesh Mohanan's avatar
Murukesh Mohanan committed
14 15
HISTSIZE=100000
SAVEHIST=100000
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
setopt appendhistory autocd extendedglob notify
bindkey -v
# End of lines configured by zsh-newuser-install

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key

# Stuff from Arch Wiki

key[Home]=${terminfo[khome]}

key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"     ]]  && bindkey  "${key[Home]}"     beginning-of-line
[[ -n "${key[End]}"      ]]  && bindkey  "${key[End]}"      end-of-line
[[ -n "${key[Insert]}"   ]]  && bindkey  "${key[Insert]}"   overwrite-mode
[[ -n "${key[Delete]}"   ]]  && bindkey  "${key[Delete]}"   delete-char
[[ -n "${key[Up]}"       ]]  && bindkey  "${key[Up]}"       up-line-or-history
[[ -n "${key[Down]}"     ]]  && bindkey  "${key[Down]}"     down-line-or-history
[[ -n "${key[Left]}"     ]]  && bindkey  "${key[Left]}"     backward-char
[[ -n "${key[Right]}"    ]]  && bindkey  "${key[Right]}"    forward-char
[[ -n "${key[PageUp]}"   ]]  && bindkey  "${key[PageUp]}"   beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]]  && bindkey  "${key[PageDown]}" end-of-buffer-or-history

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
53 54 55 56 57 58 59 60
	function zle-line-init () {
		printf '%s' "${terminfo[smkx]}"
	}
	function zle-line-finish () {
		printf '%s' "${terminfo[rmkx]}"
	}
	zle -N zle-line-init
	zle -N zle-line-finish
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
61 62 63 64 65
fi

autoload -U promptinit
promptinit

Murukesh Mohanan's avatar
Murukesh Mohanan committed
66
[[ -d $HOME/.cache/zsh ]] || mkdir -p "$HOME/.cache/zsh"
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
67
DIRSTACKFILE="$HOME/.cache/zsh/dirs"
Murukesh Mohanan's avatar
Murukesh Mohanan committed
68

Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
69
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
70
	dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
Murukesh Mohanan's avatar
Murukesh Mohanan committed
71
	[[ -z $ITERM_PROFILE ]] && [[ -d $dirstack[1] ]] && cd $dirstack[1]
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
72 73
fi
chpwd() {
74
	print -l $PWD ${(u)dirstack} >$DIRSTACKFILE
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
}

DIRSTACKSIZE=20

setopt autopushd pushdsilent pushdtohome

## Remove duplicate entries
setopt pushdignoredups

## This reverts the +/- operators.
setopt pushdminus

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

alias l='ls --color=auto'
Murukesh Mohanan's avatar
Murukesh Mohanan committed
92
alias ll='ls --color=auto -Ahl'
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
93 94 95
alias g='grep --color=auto'
alias h='history | grep'

Murukesh Mohanan's avatar
Murukesh Mohanan committed
96 97
alias sz='sudo -i zsh -l'

Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
98 99 100 101 102 103 104 105 106 107
autoload -U colors && colors
if [[ -n $SSH_TTY ]]
then
	PROMPT="%{$fg[green]%}%B%n%{$reset_color%}@%{$fg_bold[blue]%}%m%{$fg[white]%}|%{$fg_bold[yellow]%}[%?] %{$fg_bold[cyan]%}%1~%b%{$reset_color%}%\$ %{$fg_bold[yellow]%}"
else
	PROMPT="%{$fg[green]%}%B%n%{$reset_color%}%{$fg[white]%}|%{$fg_bold[yellow]%}[%?] %{$fg_bold[cyan]%}%1~%b%{$reset_color%}%\$ %{$fg_bold[yellow]%}"
fi
RPROMPT="%{$reset_color%}"

case $TERM in
Murukesh Mohanan's avatar
Murukesh Mohanan committed
108
	xterm*|screen*)
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
109 110
		if [[ -n $SSH_TTY ]]
		then
Murukesh Mohanan's avatar
Murukesh Mohanan committed
111
			precmd () {print -Pn "\e]0;%m: %2~\a"}
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
112 113 114 115 116 117
		else
			precmd () {print -Pn "\e]0;%2~\a"}
		fi
		;;
esac

118 119
setopt appendhistory histignorespace histignorealldups histnostore histreduceblanks histsavenodups
autoload is-at-least
Murukesh Mohanan's avatar
Murukesh Mohanan committed
120
if is-at-least 5.3.0 $ZSH_VERSION
121 122 123 124 125
then
	setopt incappendhistorytime
else
	setopt incappendhistory
fi
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
126 127 128 129 130 131

# Search backwards and forwards with a pattern
bindkey -M vicmd '/' history-incremental-pattern-search-backward
bindkey -M vicmd '?' history-incremental-pattern-search-forward

# set up for insert mode too
Murukesh Mohanan's avatar
Murukesh Mohanan committed
132 133
bindkey -M viins '^R' history-incremental-search-backward
bindkey -M viins '^F' history-incremental-search-forward
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
134 135

bindkey '^[[1;5D' backward-word
136
bindkey '^[[1;5C' forward-word
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
137 138 139 140 141 142 143 144

# Help from Arch

autoload -U run-help
autoload run-help-git
alias help=run-help

ssht () {
Murukesh Mohanan's avatar
Murukesh Mohanan committed
145
	ssh -Xt "$@" '$SHELL -lic byobu'
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
146 147 148 149
}

# pip zsh completion start
function _pip_completion {
150 151 152 153 154 155
	local words cword
	read -Ac words
	read -cn cword
	reply=( $( COMP_WORDS="$words[*]" \
				COMP_CWORD=$(( cword-1 )) \
				PIP_AUTO_COMPLETE=1 $words[1] ) )
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
156 157 158 159
}
compctl -K _pip_completion pip
# pip zsh completion end

Murukesh Mohanan's avatar
Murukesh Mohanan committed
160 161 162 163 164 165 166 167 168 169 170
if [[ -n $COLORTERM ]]
then
	case $TERM in
		xterm*)
			TERM=xterm-256color
			;;
		screen*)
			TERM=screen-256color
			;;
	esac
fi
171
export TERM
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
172
export CDPATH="$CDPATH:$HOME"
Murukesh Mohanan's avatar
Murukesh Mohanan committed
173 174 175
export MANPAGER='vim -'
export MANWIDTH=80

176 177
setopt BRACE_CCL

Murukesh Mohanan's avatar
Murukesh Mohanan committed
178 179 180
autoload -U edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
Murukesh Mohanan's avatar
Murukesh Mohanan committed
181

182 183 184 185 186 187
# [[ -f ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] &&
# 	. ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[[ -f ~/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh ]] &&
	. ~/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
[[ -f ~/.conflocal/$CONFLOCAL/.zshrc ]] &&
	. ~/.conflocal/$CONFLOCAL/.zshrc