Created
April 19, 2010 17:45
-
-
Save dentarg/371346 to your computer and use it in GitHub Desktop.
My .zshrc file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/zsh | |
| # | |
| # jage <[email protected]> http://jage.se | |
| # dentarg <[email protected]> http://dentarg.net | |
| # | |
| # Settings | |
| #OPENBSD_CVS='[email protected]:/cvs' | |
| OPENBSD_CVS='[email protected]:/cvs' | |
| NETBSD_CVS='[email protected]:/cvsroot' | |
| FREEBSD_CVS='[email protected]:/home/ncvs' | |
| ZSHRC_URL='http://dentarg.net/files/configs/dot.zshrc' | |
| VIMRC_URL='http://dentarg.net/files/configs/dot.vimrc' | |
| ARCH=`uname -m` | |
| OS=`uname` | |
| if [ $OS = SunOS ]; then | |
| HOSTNAME=`hostname | cut -f 1 -d .` | |
| else | |
| HOSTNAME=`hostname -s` | |
| fi | |
| # Functions and aliases | |
| function load_keychain() { | |
| if [ -x $1 ]; then | |
| $1 -q $2 | |
| source ~/.keychain/`hostname`-sh > /dev/null | |
| fi | |
| } | |
| alias ri="LESS='-fREXMM' ri -f ansi" | |
| # Defaults | |
| PREFIX='/usr/local' | |
| ## OS and/or Machine | |
| case $OS in | |
| OpenBSD) | |
| if [ '' = "`/sbin/sysctl kern.version | grep '\-current'`" ]; then | |
| VERSION=`uname -r` | |
| else | |
| VERSION='snapshots' | |
| fi | |
| # Get colors in terminal and nice ending slash | |
| if which colorls &> /dev/null; then | |
| alias ls='colorls -FG' | |
| fi | |
| alias update="ftp ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="ftp ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| CVSROOT=${OPENBSD_CVS} | |
| PKG_PATH="ftp://ftp.su.se/pub/OpenBSD/${VERSION}/packages/${ARCH}/" | |
| PREFIX="/usr/local" | |
| dstart() { env $1=YES sudo sh /etc/rc.local | sed 's/starting local daemons/Started/' } | |
| mesg n | |
| ;; | |
| NetBSD) | |
| PREFIX=('/usr/local' '/usr/pkg') | |
| CVSROOT=${NETBSD_CVS} | |
| alias update="ftp ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="ftp ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| ;; | |
| FreeBSD) | |
| PREFIX='/usr/local' | |
| CVSROOT=${FREEBSD_CVS} | |
| path+='/usr/local/etc/rc.d' | |
| # Get colors in terminal and nice ending slash | |
| alias ls='ls -HFG' | |
| alias update="ftp ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="ftp ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| alias disks="cat /var/run/dmesg.boot | grep -E 'ad(.|..):'" | |
| ;; | |
| Darwin) | |
| PREFIX=('/usr/local' '/opt/local') | |
| # Get colors in terminal and nice ending slash | |
| alias ls='ls -FGH' | |
| alias update="ftp ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="ftp ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| function fingerprints() { | |
| ssh-keygen -l -f /private/etc/ssh_host_dsa_key.pub | |
| ssh-keygen -l -f /private/etc/ssh_host_rsa_key.pub | |
| } | |
| ;; | |
| DragonFly) | |
| PREFIX=('/usr/local' '/usr/pkg') | |
| # Get colors in terminal and nice ending slash | |
| alias ls='ls -FG' | |
| alias update="ftp ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="ftp ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| ;; | |
| Linux) | |
| # Get colors in terminal and nice ending slash | |
| alias ls='ls --color' | |
| export LS_COLORS='di=36:fi=0:ln=35:pi=5:so=105:bd=5:cd=5:or=31:mi=0:ex=31:*.rpm=90' | |
| alias update="wget ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="wget ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| # Makes backspace work in screen under Ubuntu | |
| bindkey "^[[3~" backward-delete-char | |
| PREFIX=('/var/lib/gems/1.8') | |
| ;; | |
| SunOS) | |
| stty erase ^\? | |
| alias update="wget ${ZSHRC_URL};mv dot.zshrc ~/.zshrc;source ~/.zshrc" | |
| alias update_vimrc="wget ${VIMRC_URL};mv dot.vimrc ~/.vimrc" | |
| PREFIX=('/opt/sfw' '/usr/sfw' '/usr/local' '/usr') | |
| # Machines | |
| if [ `hostname | cut -f 2 -d .` = ida ]; then | |
| PREFIX=('/usr/local/' '/sw/gnu/' '/usr/sfw/' | |
| '/student' '/sw/gcc-3.4.4' '/sw/emacs-21.4' | |
| '/sw/xemacs-21.4.12' '/sw/staroffice-8.0/usr/' | |
| '/sw/subversion-1.4.3/bin/svn' '/sw/modules') | |
| fi | |
| ;; | |
| esac | |
| export PKG_PATH | |
| export CVSROOT | |
| # OS specific local paths | |
| for i in ${PREFIX}; do | |
| path+=(${i}{/bin,/sbin,/libexec}) | |
| manpath+=(${i}/man) | |
| # jage är noob? | |
| # path=(${i}{/bin,/sbin} $path) | |
| # manpath=(${i}/man $path) | |
| done | |
| path+=( | |
| . | |
| ~/bin | |
| ~/local_bin | |
| ~/local/bin | |
| /bin | |
| /sbin | |
| /usr/bin | |
| /usr/sbin | |
| /usr/X11R6/bin | |
| ) | |
| manpath=( | |
| /usr/man | |
| /usr/share/man | |
| /usr/X11R6/man | |
| /opt/local/share/man/ | |
| ~/local/man | |
| ) | |
| # Unique entries | |
| typeset -U path manpath | |
| # Nice colors in terminal | |
| export LSCOLORS='gxfxexdxbxegedabagacad' | |
| # titlebar and xterm-color | |
| case $TERM in | |
| xterm*) | |
| precmd () {print -Pn "\e]0;%m: %~\a"} | |
| preexec () { print -Pn "\e]0;%m: $1\a" } | |
| if [ $OS = SunOS ]; then | |
| TERM='xterm' | |
| else | |
| TERM='xterm-color' | |
| fi | |
| ;; | |
| rxvt) | |
| precmd () {print -Pn "\e]0;%n@%m: %~\a"} | |
| preexec() { print -Pn "\e]0;%m: $1\a" } | |
| ;; | |
| esac | |
| # Magically quote urls | |
| autoload -U url-quote-magic | |
| zle -N self-insert url-quote-magic | |
| # vim | |
| if which vim &> /dev/null; then | |
| EDITOR='vim' | |
| else | |
| EDITOR='vi' | |
| fi | |
| export EDITOR | |
| # History | |
| export HISTFILE=~/.zsh_history | |
| export HISTSIZE=900000000 | |
| export SAVEHIST=900000000 | |
| # Language | |
| export LANGUAGE=C | |
| export LC_LANG=C | |
| export LC_ALL=C | |
| # Prompt | |
| PROMPT='%(#.#.$) ' | |
| RPROMPT='%n@%m %~' | |
| # SSH | |
| CVS_RSH='ssh' | |
| RSYNC_RSH='ssh' | |
| # Disable "You have new mail." | |
| # Needed at Lysator | |
| unset MAILCHECK | |
| # Options | |
| setopt \ | |
| autocd \ | |
| hash_dirs \ | |
| no_beep \ | |
| no_check_jobs \ | |
| # zcalc > bc | |
| autoload -U zcalc | |
| ## Completion | |
| autoload -U compinit | |
| compinit | |
| # Messages | |
| zstyle ':completion:*:descriptions' format '%B%d%b' | |
| # Completers to use | |
| zstyle ':completion:*' completer _complete _prefix | |
| zstyle ':completion::prefix-1:*' completer _complete | |
| zstyle ':completion:incremental:*' completer _complete _correct | |
| zstyle ':completion:predict:*' completer _complete | |
| # Indexes before parameters in subscripts | |
| zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters | |
| # Match uppercase from lowercase | |
| zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' | |
| # Completion caching | |
| zstyle ':completion::complete:*' use-cache 1 | |
| zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST | |
| # Users | |
| zstyle ':completion:*' users \ | |
| dentarg ragpa737 | |
| # Emacs mode | |
| set -o emacs | |
| # rake completion | |
| if [ -f $HOME/.rake_completion.zsh ]; then | |
| source $HOME/.rake_completion.zsh | |
| fi | |
| # Alias | |
| alias lsa='ls -alh' | |
| alias mv='mv -i' | |
| alias cp='cp -i' | |
| alias wget='wget --no-check-certificate' | |
| # Keys | |
| #bindkey '^[[2~' overwrite-mode | |
| #bindkey '^[[3~' delete-char | |
| #bindkey '^[[H' beginning-of-line | |
| #bindkey '^[[F' end-of-line | |
| #bindkey '^[[1~' beginning-of-line | |
| #bindkey '^[[4~' end-of-line | |
| bindkey "^?" backward-delete-char | |
| bindkey "^[[3~" delete-char | |
| # http://github.com/jage/home/commit/0224efc8321ccb56a3cb72df72b4a70e8861eb44 | |
| bindkey "\e[5C" forward-word | |
| bindkey "\e[5D" backward-word | |
| # Load machine specific settings | |
| if [ -f ${HOME}/.zshrc_${HOSTNAME} ]; then | |
| source ${HOME}/.zshrc_${HOSTNAME} | |
| fi | |
| alias show_fingerprint='known_fingerprint' | |
| alias show_fingerprints='known_fingerprint' | |
| alias unzip='unzip -n' | |
| alias unrar='unrar e -y' | |
| # ZFS list snapshots | |
| function snaps() { | |
| if [ "X${1}" = "X" ]; then | |
| echo "Usage: snaps pool/filsystem" | |
| return | |
| fi | |
| zfs list $1 | |
| zfs list -r -t snapshot $1 | |
| } | |
| # SSH fingerprints | |
| function known_fingerprint() { | |
| if [ "X${1}" = "X" ]; then | |
| echo "Usage: hostname" | |
| return | |
| fi | |
| HOSTNAME=$1 | |
| TMPFILE=`mktemp /tmp/example.XXXXXXXXXX` || exit 1 | |
| ssh-keygen -F $HOSTNAME > $TMPFILE | |
| ssh-keygen -l -f $TMPFILE | |
| rm $TMPFILE | |
| } | |
| function fingerprints() { | |
| ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub | |
| ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment