aboutsummaryrefslogtreecommitdiffstats
path: root/.zshrc
blob: af868793b19f1e9d8a2235079392655b89050bf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
66
67
68
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
zstyle ':completion:*' completer _complete _ignored 
zstyle :compinstall filename '~/.zshrc'
setopt completealiases
setopt interactivecomments

autoload -U compinit
compinit
autoload -U colors
colors

HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt HIST_IGNORE_DUPS

# urxvt does visual mode just fine, and i don't compose
# any large strings in a shell, so treating it as always
# insert mode is more sensible
bindkey -e
setopt notify
unsetopt beep

##################### MISC ####################

# path for haskell builds
if [[ -d ~/.cabal/bin ]]; then
	PATH=$PATH:~/.cabal/bin
fi

if [[ -d ~/.cabal-sandbox/bin ]]; then
	PATH=$PATH:~/.cabal-sandbox/bin
fi

# dynamic title
if [[ "$TERM" == "rxvt-256color" ]]; then

	precmd() {
		print -Pn "\e]0;zsh: %(1j,%j job%(2j|s|); ,)%~\a"
	}

	preexec() {
		printf "\033]0;%s\a" "$1"
	}

fi

#################### PROMPT ###################
PROMPT="%{%B$fg[white]%}┌["
# if non-zero, previous return val
PROMPT+="%(0?..$fg[red]%?$fg[white]:)"
# if any, number of jobs
PROMPT+="%(1j.$fg[green]%j$fg[white]:.)"
# name and host (red for root)
PROMPT+="%{%(!.$fg[red].$fg[magenta])%}%n@%M%E "
# current location, with one level of parent context
PROMPT+="%{$fg[blue]%}%2c"
# newline
PROMPT+="%{$fg[white]%}]%{%b$reset_color%}
"
PROMPT+="%{%B$fg[white]%}└: %{%b$reset_color%}"


################# HIGHLIGHTING ################
if [[ -f '/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' ]]; then
	source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
else
	source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)

#ZSH_HIGHLIGHT_STYLES[alias]="fg=yellow"
#ZSH_HIGHLIGHT_STYLES[builtin]="fg=yellow"
#ZSH_HIGHLIGHT_STYLES[function]="fg=yellow"
#ZSH_HIGHLIGHT_STYLES[command]="fg=yellow"

ZSH_HIGHLIGHT_STYLES[single-quoted-argument]="fg=red"
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]="fg=red"

# highlight comments
ZSH_HIGHLIGHT_PATTERNS+=('\#*' 'fg=cyan')

################# KEYBINDINGS #################
typeset -g -A key

key[F1]='^[[11~'
key[F2]='^[[12~'
key[F3]='^[[13~'
key[F4]='^[[14~'
key[F5]='^[[15~'
key[F6]='^[[17~'
key[F7]='^[[18~'
key[F8]='^[[19~'
key[F9]='^[[20~'
key[F10]='^[[21~'
key[F11]='^[[23~'
key[F12]='^[[24~'
key[Backspace]='^?'
key[Insert]='^[[2~'
key[Home]='^[[7~'
key[PageUp]='^[[5~'
key[Delete]='^[[3~'
key[End]='^[[8~'
key[PageDown]='^[[6~'
key[Up]='^[[A'
key[Left]='^[[D'
key[Down]='^[[B'
key[Right]='^[[C'

bindkey ${key[Backspace]} backward-delete-char
bindkey ${key[Insert]}    overwrite-mode
bindkey ${key[Home]}      beginning-of-line
bindkey ${key[Delete]}    delete-char
bindkey ${key[End]}       end-of-line
bindkey ${key[Up]}        up-line-or-search
bindkey ${key[Left]}      backward-char
bindkey ${key[Down]}      down-line-or-search
bindkey ${key[Right]}     forward-char
bindkey ${key[PageUp]}    history-beginning-search-backward
bindkey ${key[PageDown]}  history-beginning-search-forward
bindkey '^W' backward-kill-word
bindkey '^U' backward-kill-line
bindkey '^P' up-history
bindkey '^N' down-history

################# OS SPECIFIC #################
case $(uname) in 
	FreeBSD)
		source ~/.zshrc-freebsd
		;;
	Linux)
		source ~/.zshrc-linux
		if [[ -e ~/.zshrc-linux-desktop ]]; then
			source ~/.zshrc-linux-desktop
		fi
		;;
	*)
		echo -e '[-- OS UNRECOGNISED --]'
esac