aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bash/bashrc118
-rwxr-xr-xinstall2
-rw-r--r--zsh/zshenv13
-rw-r--r--zsh/zshrc124
4 files changed, 205 insertions, 52 deletions
diff --git a/bash/bashrc b/bash/bashrc
index d3fedef0..ad9a5c20 100644
--- a/bash/bashrc
+++ b/bash/bashrc
@@ -1,6 +1,9 @@
# Don't do anything if not running interactively.
[ -z "$PS1" ] && return
+# Use vi as my text editor.
+export EDITOR=vi
+
# Keep plenty of history.
unset HISTFILESIZE
HISTSIZE=1000000
@@ -38,76 +41,87 @@ shopt -s globstar &>/dev/null
# Append rather than overwrite Bash history.
shopt -s histappend &>/dev/null
-# Simple prompt.
-PS1='\u@\h:\w\$ '
+# Use completion, if available.
+[[ -e /etc/bash_completion ]] && . /etc/bash_completion
+
+# SSH agent setup, if available.
+[[ -e ~/.ssh/agent ]] && . ~/.ssh/agent
+
+# Turn off annoying and useless flow control keys.
+stty -ixon
+
+# Never beep at me.
+setterm -bfreq 0
+
+# Sensible prompts, we'll work out colors shortly.
+PS1='\u@\h:\w\$'
PS2='...'
-# Set up options for ls; use color.
+# Start stacking up options for ls and grep.
LS_OPTS=
-if ls --help | grep -- --color &>/dev/null; then
- hash dircolors &>/dev/null && eval "$(dircolors -b)"
- LS_OPTS="$LS_OPTS --color=auto"
-fi
-alias ls="ls $LS_OPTS"
-
-# Set up options for grep; exclude version control files, use color.
GREP_OPTS=
+
+# If we're using an xterm, force 256 colors.
+case "$TERM" in
+ xterm*)
+ TERM=xterm-256color
+ ;;
+esac
+
+# If we have a color terminal, do colory things.
+case "$TERM" in
+ *color)
+
+ # Change prompt color depending on whether I'm root or not.
+ if [[ $EUID -eq 0 ]]; then
+ PS1='\[\e[1;31m\]'${PS1}'\[\e[0m\]'
+ else
+ PS1='\[\e[1;32m\]'${PS1}'\[\e[0m\]'
+ fi
+
+ # Get colouring for ls and grep if available.
+ hash dircolors &>/dev/null && eval "$(dircolors -b)"
+ if ls --help | grep -- --color &>/dev/null; then
+ LS_OPTS="${LS_OPTS} --color=auto"
+ fi
+ if grep --help | grep -- --color &>/dev/null; then
+ GREP_OPTS="${GREP_OPTS} --color=auto"
+ fi
+ ;;
+esac
+
+# Set up more options for grep; exclude version control files.
if grep --help | grep -- --exclude &>/dev/null; then
for PATTERN in .git .gitignore .gitmodules; do
- GREP_OPTS="$GREP_OPTS --exclude=$PATTERN"
+ GREP_OPTS="${GREP_OPTS} --exclude=${PATTERN}"
done
fi
if grep --help | grep -- --exclude-dir &>/dev/null; then
for PATTERN in .cvs .git .hg .svn; do
- GREP_OPTS="$GREP_OPTS --exclude-dir=$PATTERN"
+ GREP_OPTS="${GREP_OPTS} --exclude-dir=${PATTERN}"
done
fi
-if grep --help | grep -- --color &>/dev/null; then
- GREP_OPTS="$GREP_OPTS --color=auto"
-fi
-alias grep="grep $GREP_OPTS"
-# Protect innocent MySQL databases from my stupidity.
-alias mysql="mysql --safe-updates"
-
-# I always do this and I hate slow train.
-alias sl="ls"
-
-# Use completion, if available.
-if [ -e /etc/bash_completion ]; then
- . /etc/bash_completion
-
- # Use shots for hostname completion, if available.
- hash shots &>/dev/null && complete -F _known_hosts -W "$(shots)" \
- dig fping ftp host mtr nc netcat ping ping6 telnet traceroute
-fi
-
-# SSH agent setup, if available.
-if [ -e ~/.ssh/agent ]; then
- . ~/.ssh/agent
-fi
-
-# Turn off annoying and useless flow control keys.
-stty -ixon
+# Alias ls and grep with the options we've collected.
+alias ls="ls ${LS_OPTS}"
+alias grep="grep ${GREP_OPTS}"
-# Never beep at me.
-setterm -bfreq 0
+# Protect innocent MySQL databases from my stupidity.
+alias mysql='mysql --safe-updates'
-# Use vi as my text editor, if available.
-hash vi &>/dev/null && export EDITOR=vi
+# I always do this, and I hate slow train.
+alias sl='ls'
-# Terminal-specific settings.
+# Set window titles in various terminals.
case "$TERM" in
-
- # Set xterm title, use 256 colors.
- xterm*)
- PS1="\[\e]0;\h\a\]"${PS1}
- TERM=xterm-256color
- ;;
-
- # Set screen window title.
screen*)
- PROMPT_COMMAND="printf '\033k$(hostname)\033\\';"${PROMPT_COMMAND}
+ PS1='\[\ek\h\e\\\]'${PS1}
+ ;;
+ xterm*)
+ PS1='\[\e]0;\h\a\]'${PS1}
;;
esac
+# Add space suffix to the prompt now that we're done hacking it up.
+PS1="${PS1} "
+
diff --git a/install b/install
index a30a0649..120a32e0 100755
--- a/install
+++ b/install
@@ -14,6 +14,8 @@ ln -fs ".dotfiles/readline/inputrc" "${HOME}/.inputrc"
ln -fs ".dotfiles/tmux/tmux.conf" "${HOME}/.tmux.conf"
ln -fs ".dotfiles/vim/vimrc" "${HOME}/.vimrc"
ln -fs ".dotfiles/vim/gvimrc" "${HOME}/.gvimrc"
+ln -fs ".dotfiles/zsh/zshenv" "${HOME}/.zshenv"
+ln -fs ".dotfiles/zsh/zshrc" "${HOME}/.zshrc"
# Link in directories, removing whatever's already there first.
if [ -e "${HOME}/.vim" ]; then
diff --git a/zsh/zshenv b/zsh/zshenv
new file mode 100644
index 00000000..a25472a0
--- /dev/null
+++ b/zsh/zshenv
@@ -0,0 +1,13 @@
+# Add ~/bin to the path if it exists.
+if [[ -d "$HOME/bin" ]]; then
+ PATH="$HOME/bin:$PATH"
+fi
+
+# Add machine-specific local file if it exists.
+if [[ -e "$HOME/.zshenv_local" ]]; then
+ . "$HOME/.zshenv_local"
+fi
+
+# None of this UTF8 drawing characters nonsense.
+export NCURSES_NO_UTF8_ACS=1
+
diff --git a/zsh/zshrc b/zsh/zshrc
new file mode 100644
index 00000000..aa2c8217
--- /dev/null
+++ b/zsh/zshrc
@@ -0,0 +1,124 @@
+# Use emacs keybindings for shell.
+bindkey -e
+
+# Use vi as my text editor.
+export EDITOR=vi
+
+# Keep plenty of history.
+HISTFILE=~/.zsh_history
+HISTSIZE=1000000
+SAVEHIST=1000000
+
+# Don't worry too much about sending me long lists.
+LISTMAX=500
+
+# Append history lines directly.
+setopt appendhistory
+
+# Push a directory onto the stack whenever changed.
+setopt autopushd
+
+# Allow completing options for aliases.
+setopt completealiases
+
+# Use special globbing features.
+setopt extendedglob
+
+# Save a lot more information to the history file.
+setopt extendedhistory
+
+# Ignore duplicate history.
+setopt histignorealldups
+
+# Ignore duplicate directories on the stack.
+setopt pushdignoredups
+
+# Always retrieve history from file, not memory.
+setopt sharehistory
+
+# Put completions above my prompt, not below it.
+unsetopt alwayslastprompt
+
+# Don't beep at me.
+unsetopt beep
+
+# Don't put filetype suffices in lists.
+unsetopt listtypes
+
+# Use zsh's built-in autocompletion.
+autoload -Uz compinit && compinit
+
+# Make completion expand and correct helpfully.
+zstyle ':completion:*' completer _expand _complete _correct _approximate
+
+# SSH agent setup, if available.
+[[ -e ~/.ssh/agent ]] && . ~/.ssh/agent
+
+# Sensible prompts, we'll work out colours shortly.
+PS1="%n@%m:%~%(!.#.$)"
+PS2="..."
+
+# Start stacking up options for ls and grep.
+LS_OPTS=
+GREP_OPTS=
+
+# If we're using an xterm, force 256 colors.
+if [[ $TERM == xterm* ]]; then
+ TERM=xterm-256color
+fi
+
+# If we have a color terminal, do colory things.
+if [[ $TERM == *color ]]; then
+
+ # Change prompt color depending on whether I'm root or not.
+ PS1="%{%(!.%F{red}.%F{green})%B%}${PS1}%{%b%f%}"
+
+ # Get colouring for ls and grep if available.
+ hash dircolors &>/dev/null && eval "$(dircolors -b)"
+ if ls --help | grep -- --color &>/dev/null; then
+ LS_OPTS="${LS_OPTS} --color=auto"
+ fi
+ if grep --help | grep -- --color &>/dev/null; then
+ GREP_OPTS="${GREP_OPTS} --color=auto"
+ fi
+
+ # Use same colors for completion.
+ zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
+ zstyle ':completion:*' list-colors ''
+fi
+
+# Set up more options for grep; exclude version control files.
+if grep --help | grep -- --exclude &>/dev/null; then
+ for PATTERN in .git .gitignore .gitmodules; do
+ GREP_OPTS="${GREP_OPTS} --exclude=${PATTERN}"
+ done
+fi
+if grep --help | grep -- --exclude-dir &>/dev/null; then
+ for PATTERN in .cvs .git .hg .svn; do
+ GREP_OPTS="${GREP_OPTS} --exclude-dir=${PATTERN}"
+ done
+fi
+
+# Alias ls and grep with the options we've collected.
+alias ls="ls ${LS_OPTS}"
+alias grep="grep ${GREP_OPTS}"
+
+# Protect innocent MySQL databases from my stupidity.
+alias mysql='mysql --safe-updates'
+
+# I always do this, and I hate slow train.
+alias sl='ls'
+
+# Set window titles in various terminals. Doesn't work yet.
+case $TERM in
+ screen*)
+ precmd () {print -Pn "\ek%m\e\\"}
+ ;;
+ xterm*)
+ precmd () {print -Pn "\e]0;%m\a"}
+ ;;
+esac
+
+# Add space suffix to the prompt now that we're done hacking it up.
+PS1="${PS1} "
+