]> git.draconx.ca Git - zshconf.git/blob - zshrc
zshrc: Add bindings for the FreeBSD console.
[zshconf.git] / zshrc
1 # Configuration for interactive shells.
2 #
3 # Copyright (C) 2009 Nick Bowler
4 #
5 # Copying and distribution of this file, with or without modification,
6 # are permitted in any medium without royalty provided the copyright
7 # notice and this notice are preserved.  This file is offered as-is,
8 # without any warranty.
9
10 if [[ -n $HOME ]]; then
11         HISTFILE=$HOME/.zsh_history
12         SAVEHIST=1000
13 fi
14 HISTSIZE=1000
15
16 bindkey -e
17
18 case $TERM in
19 rxvt*)
20         if [[ $TERM == rxvt-unicode ]]; then
21                 [[ -z $COLORTERM ]] && export COLORTERM='rxvt-xpm'
22                 [[ -z $COLORFGBG ]] && export COLORFGBG='15;default;0'
23         fi
24
25         bindkey '\e[3~' delete-char
26         bindkey '\e[8~' end-of-line
27         bindkey '\e[7~' beginning-of-line
28 ;;
29 screen*|linux)
30         bindkey '\e[3~' delete-char
31         bindkey '\e[4~' end-of-line
32         bindkey '\e[1~' beginning-of-line
33 ;;
34 xterm)
35         bindkey '\e[3~' delete-char
36         bindkey '\e[F'  end-of-line
37         bindkey '\e[H'  beginning-of-line
38         bindkey '\eOH'  beginning-of-line
39         bindkey '\eOF'  end-of-line
40 ;;
41 cons25)
42         bindkey '^?'    delete-char
43         bindkey '\e[F'  end-of-line
44         bindkey '\e[H'  beginning-of-line
45 ;;
46 esac
47
48 # Set the xterm title
49 case $TERM in
50         xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
51                 settitle() { print -Pn $'\e]0;%n@%m %33<...<%~%<<\a' }
52                 ;;
53         screen)
54                 settitle() { print -Pn $'\e_%n@%m %33<...<%~%<<\e\\' }
55                 ;;
56         *)
57                 settitle() { }
58                 ;;
59 esac
60
61 # Show the return code of failed commands, but don't be noisy about it.
62 precmd() {
63         settitle
64
65         if [[ -n $__NEWRUN ]]; then
66                 RPS1='%(0?,,%B%F{red}RC=%?%f%b)'
67                 unset __NEWRUN
68         else
69                 unset RPS1
70         fi
71 }
72
73 preexec() {
74         __NEWRUN=yes
75 }
76
77 # A gentoo-like prompt.
78 PS1='%B%(!,%F{red},%F{green}%n@)%m %F{blue}%33<...<%~%<< %#%f%b '
79
80 if [ -n $COLORTERM ]; then
81         # Assorted colour-related options
82         export MINICOM="-c on"
83 fi
84
85 if [[ -n $SSH_CONNECTION ]]; then
86         PS1=${PS1/green/yellow}
87 fi
88
89 # Locale
90 export LANG=en_CA.UTF-8
91 export LC_COLLATE=ja_JP.UTF-8
92
93 # I like colours
94 alias ls='ls --color=auto'
95 alias grep='grep --color=auto'
96
97 # I hate mistakes
98 alias mv='mv -i'
99 alias rm='rm -i'
100 alias cp='cp -i'