.zshrc 5.36 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=10000
SAVEHIST=10000
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 53 54 55 56 57 58 59 60 61 62 63 64 65
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
    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
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
  dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
  [[ -d $dirstack[1] ]] && cd $dirstack[1]
fi
chpwd() {
  print -l $PWD ${(u)dirstack} >$DIRSTACKFILE
}

DIRSTACKSIZE=20

setopt autopushd pushdsilent pushdtohome

## Remove duplicate entries
setopt pushdignoredups

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

export DEBEMAIL="murukesh@cse.iitb.ac.in"
export DEBFULLNAME="Murukesh Mohanan"

# 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
95
alias ll='ls --color=auto -Ahl'
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
96 97 98
alias g='grep --color=auto'
alias h='history | grep'

Murukesh Mohanan's avatar
Murukesh Mohanan committed
99 100
alias sz='sudo -i zsh -l'

Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
101 102 103 104 105 106 107 108 109 110
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
111
	xterm*|screen*)
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
112 113
		if [[ -n $SSH_TTY ]]
		then
Murukesh Mohanan's avatar
Murukesh Mohanan committed
114
			precmd () {print -Pn "\e]0;%m: %2~\a"}
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
		else
			precmd () {print -Pn "\e]0;%2~\a"}
		fi
		;;
esac

setopt appendhistory histignorespace histignorealldups histnostore histreduceblanks histsavenodups incappendhistorytime

# 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
bindkey -M viins '^R' history-incremental-pattern-search-backward
bindkey -M viins '^F' history-incremental-pattern-search-forward

bindkey '^[[1;5D' backward-word
132
bindkey '^[[1;5C' forward-word
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
133 134 135 136 137 138 139 140

# Help from Arch

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

ssht () {
Murukesh Mohanan's avatar
Murukesh Mohanan committed
141
	ssh -Xt "$@" byobu-screen
Murukesh Mohanan's avatar
re-init  
Murukesh Mohanan committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155
}

# pip zsh completion start
function _pip_completion {
  local words cword
  read -Ac words
  read -cn cword
  reply=( $( COMP_WORDS="$words[*]" \
             COMP_CWORD=$(( cword-1 )) \
             PIP_AUTO_COMPLETE=1 $words[1] ) )
}
compctl -K _pip_completion pip
# pip zsh completion end

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

172 173
setopt BRACE_CCL

Murukesh Mohanan's avatar
Murukesh Mohanan committed
174 175 176
autoload -U edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
Murukesh Mohanan's avatar
Murukesh Mohanan committed
177

178 179 180 181
[[ -f $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] &&
	. "$HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
[[ -f $HOME/.conflocal/$CONFLOCAL/.zshrc ]] && 
	. "$HOME/.conflocal/$CONFLOCAL/.zshrc"