]> git.draconx.ca Git - zshconf.git/blob - zshrc
Fix up zshrc for TERM=rxvt-unicode-256color
[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=10000
13 fi
14 HISTSIZE=10000
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|cygwin)
30         bindkey '\e[3~' delete-char
31         bindkey '\e[4~' end-of-line
32         bindkey '\e[1~' beginning-of-line
33         bindkey '\eOM'  accept-line
34 ;;
35 xterm)
36         bindkey '\e[3~' delete-char
37         bindkey '\e[F'  end-of-line
38         bindkey '\e[H'  beginning-of-line
39         bindkey '\eOH'  beginning-of-line
40         bindkey '\eOF'  end-of-line
41 ;;
42 cons25)
43         bindkey '^?'    delete-char
44         bindkey '\e[F'  end-of-line
45         bindkey '\e[H'  beginning-of-line
46 ;;
47 esac
48
49 # Keymap-specific bindings
50 case $KEYMAP in
51 colemak)
52         bindkey '^R'    history-incremental-search-forward
53         bindkey '^P'    history-incremental-search-backward
54         ;;
55 esac
56
57 # Set the xterm title
58 case $TERM in
59         xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
60                 settitle() { print -Pn $'\e]0;%n@%m %33<...<%~%<<\a' }
61                 ;;
62         screen)
63                 settitle() { print -Pn $'\e_%n@%m %33<...<%~%<<\e\\' }
64                 ;;
65         *)
66                 settitle() { }
67                 ;;
68 esac
69
70 # Show the return code of failed commands, but don't be noisy about it.
71 precmd() {
72         settitle
73
74         if [[ -n $__NEWRUN ]]; then
75                 RPS1='%(0?,,%B%F{red}RC=%?%f%b)'
76                 unset __NEWRUN
77         else
78                 unset RPS1
79         fi
80 }
81
82 preexec() {
83         __NEWRUN=yes
84 }
85
86 # A gentoo-like prompt.
87 PS1='%B%(!,%F{red},%F{green}%n@)%m %F{blue}%33<...<%~%<< %#%f%b '
88
89 if [ -n $COLORTERM ]; then
90         # Assorted colour-related options
91         export MINICOM="-c on"
92 fi
93
94 if [[ -n $SSH_CONNECTION ]]; then
95         PS1=${PS1/green/yellow}
96 fi
97
98 # Locale
99 export LANG=en_CA.UTF-8
100 export LC_COLLATE=ja_JP.UTF-8
101
102 # Default options for various utilities.
103 alias ls='ls --time-style=long-iso --color=auto'
104 alias grep='grep --color=auto'
105
106 # I hate mistakes
107 alias mv='mv -i'
108 alias rm='rm -i'
109 alias cp='cp -i'