Skip to content

Commit

Permalink
Merge remote-tracking branch 'mat/master' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	01_path
	05_editor
	05_ls
	06_git
	06_less
	10_bindkey
	10_prompt
  • Loading branch information
Superbil committed Apr 5, 2011
2 parents da8ecd4 + 6de8ac6 commit b1bc33c
Show file tree
Hide file tree
Showing 30 changed files with 779 additions and 96 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.swp
*.swo
94 changes: 89 additions & 5 deletions 01_path
@@ -1,4 +1,21 @@
path=(/usr/libexec/ $path)
#
# Set up path variables
#
# Note: it doesn't matter if directories in the lists don't exist, as they
# won't be added to the path unless they do.
#

local pathdirs mandirs funcdirs helpdirs

# Create a list of directories to add to the path
pathdirs=(
/Library/Frameworks/Python.framework/Versions/Current/bin
/usr/local/bin
/usr/local/git/bin
/usr/local/libexec/git-core
/opt/local/bin
$HOME/bin
)

# Allow Brew path
path=(/usr/local/sbin /usr/local/bin $path)
Expand All @@ -12,8 +29,75 @@ fi
path=($HOME/project/gsutil $path)
pythonpath=(${PYTHONPATH} $HOME/project/gsutil/boto)

# setup z script
. $HOME/project/z/z.sh
function precmd () {
z --add "$(pwd -P)"

# Query the gem configuration to get the correct path
# XXX: This might cause problems if you alias 'gem' to something else after the path has been setup.
if [[ -x $(which gem) ]]; then
# 's.:.' creates an array by splitting on ':'.
gemdirs=(${(s.:.)"$(gem environment gempath)"})
# The paths above don't end with /bin.
for dir ($gemdirs) { pathdirs=($pathdirs "$dir/bin") }
fi

# Add directories which exist to the path
for dir ($pathdirs) {
if [[ -d $dir ]]; then
path=($dir $path)
fi
}

# Allow MacPorts man pages and others
mandirs=(
/usr/local/git/man
/sw/share/man
/opt/local/man
/usr/local/man
$HOME/Library/Documentation/Local/man
)

# Add directories which exist to the manpath
for dir ($mandirs) {
if [[ -x $dir ]]; then
manpath=($manpath $dir)
fi
}

# Add function paths
local binary=$(which zsh)
local install_path=$binary:h:h # Strip bin/zsh to find installation path.

funcdirs=(
$HOME/.zsh/func
$install_path/share/zsh/$ZSH_VERSION/functions
$install_path/share/zsh/functions
$install_path/share/zsh/site-functions
/usr/share/zsh/$ZSH_VERSION/functions
/usr/share/zsh/functions
/usr/share/zsh/site-functions
)

# Add existing function directories to the fpath
for dir ($funcdirs) {
if [[ -x $dir ]]; then
fpath=($fpath $dir)
fi
}

# Directories for run-help: see 03_help.
helpdirs=(
$HOME/.zsh/help
$install_path/share/zsh/$ZSH_VERSION/zsh_help
$install_path/share/zsh/zsh_help
/usr/share/zsh/$ZSH_VERSION/zsh_help
/usr/share/zsh/zsh_help
)

for dir ($helpdirs) {
if [[ -x $dir ]]; then
helpdir=($fpath $dir)
fi
}

typeset -gU path cdpath manpath fpath helpdir

# vim: set syn=zsh:
63 changes: 63 additions & 0 deletions 03_help
@@ -0,0 +1,63 @@
# See From Bash to Z Shell, Page: 101
if [[ $(whence -v run-help) == 'run-help is a shell function' ]]; then
unalias run-help
fi
autoload -Uz run-help
# From zsh-helpfiles (see fink)
alias help=run-help

# From zsh-lovers
# Function Usage: doc packagename

# We can only easily use one documentation directory, so
# these are in priority order
docdirs=(/sw/share/doc /usr/local/share/doc /usr/share/doc)

foreach dir ($docdirs) {
if [[ -d $dir ]] then
doc() { cd $dir/$1 && ls }
gdoc() { cd $dir/$1 && $EDITOR . }
_doc() { _files -W $dir -/ }
break
fi
}

# provide useful information on globbing
H-Glob() {
echo -e "
/ directories
. plain files
@ symbolic links
= sockets
p named pipes (FIFOs)
* executable plain files (0100)
% device files (character or block special)
%b block special files
%c character special files
r owner-readable files (0400)
w owner-writable files (0200)
x owner-executable files (0100)
A group-readable files (0040)
I group-writable files (0020)
E group-executable files (0010)
R world-readable files (0004)
W world-writable files (0002)
X world-executable files (0001)
s setuid files (04000)
S setgid files (02000)
t files with the sticky bit (01000)
print *(m-1) # List files modified today.
print *(a1) # List files accessed one day ago.
print *(@) # Print links.
print *(Lk+50) # List files > 50 Kilobytes.
print *(Lk-50) # List files < 50 Kilobytes.
print **/*.c # Recursively list all c files.
print **/*.c~file.c # List all c files, except file.c
print (foo|bar).* # List files whos names start foo or bar.
print *~*.* #
chmod 644 *(.^x) # make all non-executable files publically readable
print -l *(.c|.h) # List all c and header files on their own lines.
print **/*(g:users:) # Recursively list files with the group 'users'
echo /proc/*/cwd(:h:t:s/self//) # Analogue of >ps ax | awk '{print $1}'<"
}
# vim: set syn=zsh:
22 changes: 22 additions & 0 deletions 05_apt
@@ -0,0 +1,22 @@
# Look for apt, and add some useful functions if we have it.
if [[ -x `which apt-get` ]]; then
alias apt-get='noglob sudo apt-get'
alias aptitude='noglob sudo aptitude'

upgrade () {
if [ -z $1 ] ; then
sudo apt-get update
sudo apt-get -u upgrade
else
ssh $1 sudo apt-get update
# ask before the upgrade
local dummy
ssh $1 sudo apt-get --no-act upgrade
echo -n "Process the upgrade ?"
read -q dummy
if [[ $dummy == "y" ]] ; then
ssh $1 sudo apt-get -u upgrade --yes
fi
fi
}
fi
51 changes: 40 additions & 11 deletions 05_editor
@@ -1,27 +1,56 @@
export EDITOR
export CVSEDITOR
export GIT_EDITOR

function not_run_from_ssh () {
ps x|grep "${PPID}.*sshd"|grep -v grep
echo $?
# Define an order or preference for text editors
local editors
editors=(mate mvim gvim vim vi nano pico)

# Look for the first of these editors which exists
for editor ($editors) {
if [[ -x $(which $editor) ]]; then
EDITOR=$editor
break
fi
}

if [[ -x `which mvim` && $(not_run_from_ssh) = 1 ]]; then
EDITOR="mvim -f"
else
EDITOR=`which vi`
# Some editors need specific arguments for VCS
if [[ $EDITOR == 'mvim' || $EDITOR == 'gvim' ]]; then
export CVSEDITOR="$EDITOR -f" # Don't fork.
export GIT_EDITOR="$EDITOR -f" # Don't fork.
fi

# Print a warning if there's still no editor set.
[[ -z $EDITOR ]] && print 'No editor set.'

# TextMate specific stuff:
if [[ $EDITOR == 'mate' && -x $(which bundle) && -n $(bundle) && $? = 0 && -z $SSH_CLIENT ]]; then
EDITOR="mate -w"
# Useful functions for bundle development
function reload_textmate(){
osascript -e 'tell app "TextMate" to reload bundles'
}
function bundle () {
cd "$HOME/Library/Application Support/TextMate/Bundles/$1.tmbundle"
}
_bundle() {
bundle_path="$HOME/Library/Application Support/TextMate/Bundles"
compadd $(print -l $bundle_path/*.tmbundle(:t:r))
}
fi

# Set EDITOR as default for plaintext stuff
for s in txt c cc cxx cpp; do
for s in txt tex c cc cxx cpp gp m md markdown otl; do
alias -s $s=$EDITOR
done

# Abuse the "open" command on OS X
if [[ $OSTYPE[1,6] == "darwin" ]]; then
for s in mp3 wav aac \
avi mp4 m4v mov qt mpg mpeg \
jpg png psd bmp gif tif tiff \
ps pdf html dmg; do
ogg avi mp4 m4v mov qt mpg mpeg \
jpg jpeg png psd bmp gif tif tiff \
eps ps pdf html dmg; do
alias -s $s=open
done
fi

9 changes: 9 additions & 0 deletions 05_gnu_coreutils
@@ -0,0 +1,9 @@
# Include GNU coreutils aliases if installed via homebrew
if [[ -x brew ]]; then
ALIASES=$(brew --prefix coreutils)/aliases
if [ -e $ALIASES ]; then
source $ALIASES
# Whilst experimenting I had problems with my prompt and g[
unalias [
fi
fi
4 changes: 4 additions & 0 deletions 05_grep
Expand Up @@ -2,3 +2,7 @@ if [[ -x `which ggrep` ]]; then
alias rgrep=`which grep`
alias grep='ggrep --color'
fi

# From zsh-lovers: detect gnu grep:
(grep --help 2>/dev/null |grep -- --color) >/dev/null && \
export GREP_OPTIONS='--color=auto'
22 changes: 16 additions & 6 deletions 05_ls
@@ -1,12 +1,22 @@
if [[ -x `which gls` ]]; then
alias rls=`which ls`
alias ls='gls -h --color=auto '
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'
# Unfortunatly GNU ls support -G.
elif [[ $(uname) != 'Linux' && -n `ls -G` && $? == 0 ]]; then
alias ls='ls -G'
elif [[ -n `ls --color` && $? == 0 ]]; then
# Check if ls can handle the --color option. If it can it's probably gnu.
alias ls='ls --color=auto'
fi
if [[ `uname -s` = "Darwin" ]]; then
alias ls='ls -G'

if [[ $(uname) == 'FreeBSD' || $(uname) == 'Darwin' ]]; then
export CLICOLOR="yes"
export LSCOLORS='ExfxcxdxbxEgEdabagacad'
else
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=0;32:*.jpe=0;32:*.jpeg=0;32:*.gif=0;32:*.bmp=0;32:*.pbm=0;32:*.pgm=0;32:*.ppm=0;32:*.tga=0;32:*.xbm=0;32:*.xpm=0;32:*.tif=0;32:*.tiff=0;32:*.png=0;32:*.eps=0;32:*.mpg=0;32:*.mpeg=0;32:*.avi=0;32:*.fli=0;32:*.gl=0;32:*.dl=0;32:*.xcf=0;32:*.xwd=0;32:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.flac=01;35:*.m4a=01;35:*.mpc=01;35:*.o=01;33:*.c=01;35:*.m=01;35:*.h=01;35:*.rb=01;35:*.pl=01;35:*.py=01;35:*.sh=01;35:*.m=01;35:*akefile=0;35:*tags=01;32:*~=01;30:*.swp=01;30:*README=01;31:*README.*=01;31:*readme=00;31:*.tex=01;31:*.htm=01;31:*.html=01;31:*.pdf=00;31:*.PDF=00;31:*.ps=00;31:*.PS=00;31:*.png=00;31:*.PNG=00;31:*.jpg=00;31:*.JPG=00;31:*.jpeg=00;31:*.JPEG=00;31:';
fi
alias ll="ls -al"

export CLICOLOR=1
export LSCOLORS=gxfxaxdxcxegedabagacad
alias l='ls'
alias ll='ls -al'
alias lh='ls -Alh'
alias lt='ls -Alt'
5 changes: 5 additions & 0 deletions 05_octave
@@ -0,0 +1,5 @@
if [[ -e /Applications/Octave.app/Contents/Resources/bin/octave ]]; then
alias octave='/Applications/Octave.app/Contents/Resources/bin/octave -q'
else
alias octave='octave -q'
fi
5 changes: 5 additions & 0 deletions 05_python
@@ -0,0 +1,5 @@
export PYTHONPATH=$HOME/.python_libraries
typeset -U PYTHONPATH

alias pylab='ipython -pylab -wthread'
alias easy_install='sudo easy_install'
1 change: 1 addition & 0 deletions 05_rsync
@@ -0,0 +1 @@
alias rsyncp='rsync -avz -e ssh --progress --partial '
21 changes: 20 additions & 1 deletion 05_ruby
@@ -1 +1,20 @@
alias irb='irb --readline -r irb/completion'
#
# Set up ruby
#
autoload -U get-ruby-version && get-ruby-version

# If you alias ruby to (say) ruby 1.9, this should update irb too.
# You might want to alias 'gem' here too, if you do, remember to update your path.
local irb_options="--readline -r irb/completion"

if [[ -x $(which irb$RUBY_VERSION) ]]; then
alias irb='irb$RUBY_VERSION $irb_options'
else
alias irb="irb $irb_options"
fi

export RI='-f ansi --width 70'

if [[ -x `which fri` ]]; then
alias ri=fri
fi
36 changes: 36 additions & 0 deletions 05_video
@@ -0,0 +1,36 @@
# See: http://omino.com/sw/qt_tools/
if [[ -x `which qt_export` ]]; then
create_image_mov() {
if [[ $# = 0 ]]
then
echo "Usage: $0 image_name move_name"
echo "Create movie using png compression."
echo "Example: $0 watershed_01.png (outputs watershed.mov)"
echo "Example: $0 watershed_01.png out.mov (outputs out.mov)"
else
if [[ $# > 1 ]]
then
out=$2
else
out=$(echo $aa:r | sed 's/_*[0-9]*//g').mov
fi
qt_export --sequencerate=1 $1 --video=png,1 --audio=0 --replacefile $out
fi
}
fi

if [[ -x `which mencoder` ]]; then
function mkv_to_avi(){
# Remux .mkv or .ogm to .avi with mp3 audio.
input=''
output=${input:r}.avi
mencoder $input -oac mp3lame -ovc copy -o $output
}

function mkv_to_avi(){
# Convert .mkv or .ogm to .avi with XViD and mp3 audio.
input=''
output=${input:r}.avi
mencoder $input -oac mp3lame -ovc xvid -xvidencopts pass=1 -o $output
}
fi

0 comments on commit b1bc33c

Please sign in to comment.