This commit is contained in:
SimonGreenhill 2012-01-14 23:03:41 +13:00
commit 5e8734bfd6
26 changed files with 1300 additions and 74 deletions

View file

@ -1,16 +1,14 @@
# fixme - the load process here seems a bit bizarre
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press
unsetopt noautomenu
setopt complete_in_word
setopt always_to_end
unsetopt always_to_end
WORDCHARS=''
zmodload -i zsh/complist
## case-insensitive (all),partial-word and then substring completion
# case-insensitive (all), partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE

View file

@ -4,7 +4,3 @@ alias man='nocorrect man'
alias mv='nocorrect mv'
alias mysql='nocorrect mysql'
alias mkdir='nocorrect mkdir'
alias gist='nocorrect gist'
alias heroku='nocorrect heroku'
alias ebuild='nocorrect ebuild'
alias hpodder='nocorrect hpodder'

View file

@ -3,23 +3,17 @@ setopt auto_name_dirs
setopt auto_pushd
setopt pushd_ignore_dups
alias -- -='cd -'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
alias cd/='cd /'
alias 1='cd -'
alias 2='cd +2'
alias 3='cd +3'
alias 4='cd +4'
alias 5='cd +5'
alias 6='cd +6'
alias 7='cd +7'
alias 8='cd +8'
alias 9='cd +9'
cd () {
if [[ "x$*" == "x..." ]]; then
cd ../..
@ -38,7 +32,19 @@ alias md='mkdir -p'
alias rd=rmdir
alias d='dirs -v'
# List direcory contents
alias l1='tree --dirsfirst -ChFL 1'
alias l2='tree --dirsfirst -ChFL 2'
alias l3='tree --dirsfirst -ChFL 3'
alias ll1='tree --dirsfirst -ChFupDaL 1'
alias ll2='tree --dirsfirst -ChFupDaL 2'
alias ll3='tree --dirsfirst -ChFupDaL 3'
alias l='l1'
alias ll='ll1'
# mkdir & cd to it
function mcd() {
mkdir -p "$1" && cd "$1";
}
}

30
lib/django.zsh Normal file
View file

@ -0,0 +1,30 @@
alias pm='python manage.py'
alias pmr='python manage.py runserver'
alias pmrp='python manage.py runserver_plus'
alias pmrpg='pmrp --adminmedia=`pwd`/static/admin'
alias pmsdb='python manage.py syncdb'
alias pms='python manage.py shell'
alias pmsp='python manage.py shell_plus'
alias pmlf='python manage.py loaddata fixtures/*'
alias pmt='python -W ignore::DeprecationWarning manage.py test'
alias pmdm='python manage.py datamigration'
alias pmsm='python manage.py schemamigration --auto'
alias pmsi='python manage.py schemamigration --initial'
alias pmm='python manage.py migrate'
alias pmma='python manage.py migrate --all'
alias pmml='python manage.py migrate --list'
alias pmmf='python manage.py migrate --fake'
alias pmcats='python manage.py convert_to_south'
alias gs='gunicorn_django'
alias gk='kill `cat .gunicorn.pid`'
alias gl='tail -f .gunicorn.log'
function djapp() {
mkdir -p $1/templates/$1
touch $1/__init__.py
echo "from django.db import models\n\n" > $1/models.py
echo "from django.contrib import admin\nfrom $1.models import *\n\n" > $1/admin.py
echo "from django.conf.urls.defaults import *\n\n" > $1/urls.py
}

View file

@ -10,8 +10,39 @@ function upgrade_oh_my_zsh() {
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
}
function take() {
mkdir -p $1
cd $1
function extract() {
unset REMOVE_ARCHIVE
if test "$1" = "-r"; then
REMOVE=1
shift
fi
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xvjf $1;;
*.tar.gz) tar xvzf $1;;
*.tar.xz) tar xvJf $1;;
*.tar.lzma) tar --lzma -xvf $1;;
*.bz2) bunzip $1;;
*.rar) unrar x $1;;
*.gz) gunzip $1;;
*.tar) tar xvf $1;;
*.tbz2) tar xvjf $1;;
*.tgz) tar xvzf $1;;
*.zip) unzip $1;;
*.Z) uncompress $1;;
*.7z) 7z x $1;;
*) echo "'$1' cannot be extracted via >extract<";;
esac
if [[ $REMOVE_ARCHIVE -eq 1 ]]; then
echo removing "$1";
/bin/rm "$1";
fi
else
echo "'$1' is not a valid file"
fi
}

View file

@ -4,12 +4,19 @@ function git_prompt_info() {
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
# Checks if working tree is dirty
parse_git_dirty() {
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
parse_git_dirty () {
gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)')
if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then
echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY"
fi
if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\|# Changes not staged for commit:\)$") > 0 ]]; then
echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
if [[ $(echo ${gitstat} | grep -v '^$' | wc -l | tr -d ' ') == 0 ]]; then
echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
}
@ -20,6 +27,15 @@ function git_prompt_ahead() {
fi
}
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"

View file

@ -1,6 +0,0 @@
#
# Color grep results
# Examples: http://rubyurl.com/ZXv
#
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='1;32'

View file

@ -11,6 +11,8 @@ bindkey "^[[6~" down-line-or-history
# make search up and down work, so partially type and hit up/down to find relevant stuff
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
bindkey '^p' up-line-or-search
bindkey '^n' down-line-or-search
bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line
@ -31,21 +33,6 @@ bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
# consider emacs keybindings:
#bindkey -e ## emacs key bindings
#
#bindkey '^[[A' up-line-or-search
#bindkey '^[[B' down-line-or-search
#bindkey '^[^[[C' emacs-forward-word
#bindkey '^[^[[D' emacs-backward-word
#
#bindkey -s '^X^Z' '%-^M'
#bindkey '^[e' expand-cmd-path
#bindkey '^[^I' reverse-menu-complete
#bindkey '^X^N' accept-and-infer-next-history
#bindkey '^W' kill-region
#bindkey '^I' complete-word
## Fix weird sequence that rxvt produces
#bindkey -s '^[[Z' '\t'
#

View file

@ -3,11 +3,53 @@ autoload -U url-quote-magic
zle -N self-insert url-quote-magic
## file rename magick
autoload -U zmv
bindkey "^[m" copy-prev-shell-word
## jobs
setopt long_list_jobs
## pager
export PAGER=less
export PAGER='less -R'
export LC_CTYPE=$LANG
## pretty man pages
function pman() {
man $1 -t | open -f -a Preview
}
#
## pretty JSON
function pj() {
python -mjson.tool
}
## Open current directory
alias oo='open .'
## Quick-look a file (^C to close)
alias ql='qlmanage -p 2>/dev/null'
## Start a local SMTP server and dump emails sent to it to the console
alias smtpconsole='python -m smtpd -n -c DebuggingServer localhost:1025'
## Serve the current folder on port 80
alias serve_this='python -m SimpleHTTPServer'
## Highlight-aware less command
alias hl='less -R'
## Show history
alias history='fc -l 1'
## Color grep results
## Examples: http://rubyurl.com/ZXv
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='1;32'
# Quick and dirty encryption
function encrypt() {
openssl des3 -a -in $1 -out $1.des3
}
function decrypt() {
openssl des3 -d -a -in $1 -out ${1%.des3}
}

13
lib/python.zsh Normal file
View file

@ -0,0 +1,13 @@
function wo() {
[ "$VEW_SOURCED" ] || source "$VEW_PATH"
[ -f './.venv' ] && workon `cat ./.venv` || workon $1
export VEW_SOURCED=1
}
alias deact='deactivate'
alias cdv='cd $WORKON_HOME'
function cdp () {
cd "$(python -c "import os.path as _, ${1}; \
print _.dirname(_.realpath(${1}.__file__[:-1]))"
)"
}

2
lib/redis.zsh Normal file
View file

@ -0,0 +1,2 @@
alias res='./redis-server'
alias rec='./redis-cli'

View file

@ -1,7 +0,0 @@
# get the name of the branch we are on
function rvm_prompt_info() {
ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return
echo "($ruby_version)"
}

2
lib/supervisord.zsh Normal file
View file

@ -0,0 +1,2 @@
alias ssd='sudo supervisord'
alias ssc='sudo supervisorctl'

View file

@ -1,7 +1,6 @@
# ls colors
autoload colors; colors;
export LSCOLORS="Gxfxcxdxbxegedabagacad"
#export LS_COLORS
# Enable ls colors
if [ "$DISABLE_LS_COLORS" != "true" ]