commit 83d40113d27ca6ac7f1e8459ad181ddb7216abd3 Author: michener Date: Mon Mar 19 06:17:17 2007 +0000 First import git-svn-id: http://photonzero.com/dotfiles/trunk@1 23f722f6-122a-0410-8cef-c75bd312dd78 diff --git a/.bash_aliases b/.bash_aliases new file mode 100644 index 0000000..a6a3f4d --- /dev/null +++ b/.bash_aliases @@ -0,0 +1,67 @@ +#alias ls='ls -F --color' +#[ -x /usr/games/fortune ] && /usr/games/fortune bofh-excuses +#alias la='ls -Fal --color' +#alias uptime="uptime | cowsay" +#alias date="date | cowsay" + + +#Imperatives +# enable color support of ls and also add handy aliases + #alias dir='ls --color=auto --format=vertical' + #alias vdir='ls --color=auto --format=long' + +case `uname` in +Linux) + if [ "$TERM" != "dumb" ]; then + eval "`dircolors -b`" + fi + alias ls='ls -F --color=auto' + ;; +Darwin) + alias ls='ls -FG' + ;; +FreeBSD) + alias ls='ls -FG' + ;; +*) + if [ "$TERM" != "dumb" ]; then + eval "`dircolors -b`" + fi + alias ls='ls --color=auto' + ;; +esac + + + +# some more ls aliases +alias ll='ls -lF' +#alias la='ls -A' +alias la='ls -alF' +#alias l='ls -CF' + +alias vi='vim' +alias grep="grep --color=auto" +alias screen="screen -R" + +#Cosmetic/useful +alias naim="naim --noscreen" +alias wallall="wallall -p" +alias cal="cal -3" +alias google='surfraw google' +alias hd='od -Ax -tx1z -v' + +#Sysdadmin +alias aptsearch="aptitude search" +alias openports="lsof -i 4 -n" +alias saupdate="sa-learn --mbox --spam ~/mail/spam" +alias pshosers="ps axeo pcpu,pid,user,command | sort -k 1 -r | head -11 " +alias memhosers="ps axeo size,pcpu,pid,user,command | sort -n -r | head -11 " + +#Some orly aliases +alias yarly="orly -y" +alias nowai="orly -n" +alias srsly="orly -s" + +#Funnies +alias whothefuckis='finger' +alias whoami="echo 24601" diff --git a/.bash_logout b/.bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/.bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/.bash_profile b/.bash_profile new file mode 100644 index 0000000..abb79e9 --- /dev/null +++ b/.bash_profile @@ -0,0 +1,27 @@ +# $FreeBSD: src/share/skel/dot.profile,v 1.19.2.2 2002/07/13 16:29:10 mp Exp $ +# +# .profile - Bourne Shell startup script for login shells +# +# see also sh(1), environ(7). +# + +# remove /usr/games and /usr/X11R6/bin if you want +PATH=$HOME/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin; export PATH + +# Setting TERM is normally done through /etc/ttys. Do only override +# if you're sure that you'll never log in via telnet or xterm or a +# serial line. +# Use cons25l1 for iso-* fonts +# TERM=cons25; export TERM + +BLOCKSIZE=K; export BLOCKSIZE +EDITOR=vim; export EDITOR +PAGER=less; export PAGER + +# set ENV to a file invoked each time sh is started for interactive use. +ENV=$HOME/.bashrc; export ENV +XMMS_PATH="tcp://10.42.0.2:6600" + +#alias ls='ls -FG' +#alias la='ls -FGal' +source ~/.bashrc diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..f7dec5b --- /dev/null +++ b/.bashrc @@ -0,0 +1,86 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +export HISTCONTROL=ignoredups + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +#case "$TERM" in +#xterm-color) +# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +# ;; +#*) +# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +# ;; +#esac + +case $TERM in + xterm*|rxvt*) + TITLEBAR='\[\033]0;\u@\h:\w\007\]' + ;; + *) + TITLEBAR="\033k\033\134"; +esac; +PS1="${TITLEBAR}\[\033[0m\]\[\033[0;32m\]\u\[\033[0m\]\[\033[0;37m\]@\[\033[0m\]\[\033[0;32m\]\h\[\033[0m\]\[\033[0;37m\]:\[\033[0;34m\][\[\033[1;36m\]\w\[\033[0;34m\]]\[\033[0;0m\]\$ " +#PS1="${TITLEBAR}\[\033[0m\]\[\033[0;34m\][\[\033[0m\]\[\033[1;33m\]\$(date +%H:%M)|\!\[\033[0m\]\[\033[0;34m\]] \[\033[0m\]\[\033[0;32m\]\u\[\033[0m\]\[\033[0;37m\]@\[\033[0m\]\[\033[0;32m\]\h\[\033[0m\]\[\033[0;37m\]:\[\033[0m\]\[\033[1;36m\]\w\[\033[0m\]\[\033[0;0m\]\$ " +#PS1="${TITLEBAR}\[\033[0m\]\[\033[1;34m\][\[\033[0m\]\[\033[1;33m\]\$(date +%H:%M)\[\033[0m\]\[\033[1;34m\]] \u\[\033[0m\]\[\033[0;37m\]@\[\033[0m\]\[\033[1;34m\]\h\[\033[0m\]\[\033[0;37m\]:\[\033[0m\]\[\033[1;36m\]\w\[\033[0m\]\[\033[0;0m\]\$ " +#PS1="${TITLEBAR}\[\033[0m\]\[\033[0;32m\][\$(date +%H:%M)] \[\033[0;33m\]\u\[\033[0m\]@\[\033[0;31m\]\h\[\033[1;37m\]:\[\033[0m\]\[\033[1;34m\]\w\[\033[1;37m\]\$ \[\033[0;0m\]" +# Comment in the above and uncomment this below for a color prompt +#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +# +#\[\033]0;\u@\h:\w\007\]\[\033[0m\]\[\033[0;32m\][$(date +%H:%M)] \[\033[1;33m\]\u\[\033[0m\]@\[\033[1;31m\]\h\[\033[1;37m\]:\[\033[0m\]\[\033[1;34m\]\w\[\033[1;37m\]$ \[\033[0;0m\] + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' + ;; +*) + ;; +esac + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable color support of ls and also add handy aliases +#if [ "$TERM" != "dumb" ]; then +# eval "`dircolors -b`" +# alias ls='ls --color=auto' + #alias dir='ls --color=auto --format=vertical' + #alias vdir='ls --color=auto --format=long' +#fi + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias la='ls -al' +#alias l='ls -CF' + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi diff --git a/.muttrc b/.muttrc new file mode 100644 index 0000000..7a29952 --- /dev/null +++ b/.muttrc @@ -0,0 +1,9 @@ +set alias_file=~/.mutt_alias +set folder=~/mail/ +set move=no +set mark_old=no +set pager_stop=yes +set postponed=+postponed +set signature=~/.sig +#set sort=date-received +set spoolfile=+misc diff --git a/.procmailrc b/.procmailrc new file mode 100644 index 0000000..7add98d --- /dev/null +++ b/.procmailrc @@ -0,0 +1,130 @@ +USER = michener +DEBUG = yes +VERBOSE = yes +#LOGABSTRACT = yes +#LOGFILE = /home/digital/michener/.procmaillog +MAIL = /home/michener/mail +MAILDIR = $MAIL + +### cron mail +:0 +* ^Subject: [a-z.]+ ((daily|weekly|monthly|security) (run|check) output|Postgres Vacuumdb Analyze|Postgres Backup)$ +{ + :0 + * ^From: [a-z0-9 ]+ \<(root|pgsql)(@([-a-z0-9.]+\.)?csua\.berkeley\.edu)?\>$ + /dev/null + + :0 + * ^From: (root|pgsql)(@([-a-z0-9.]+\.)?csua\.berkeley\.edu)? \([^)]*\)$ + /dev/null + + :0 + * ^From: [a-z0-9 ]+ \<(root|pgsql)(@([-a-z0-9.]+\.)?CSUA\.Berkeley\.EDU)?\>$ + /dev/null +} + +:0 +* ^From.*mailer-daemon +* ^Subject.*(notify|returned) +/dev/null + +:0 +* ^Subject:.*(Returned|failure|failed|Surveys|daily) +* ^To.*(postmaster|webmaster|hostmaster|survey-owner|mailer-daemon|owner-csua|www) +/dev/null + +:0 +* ^From.*cron +/dev/null +## keg & scotch daily output +:0 +* ^Subject:.*(keg|scotch) +* ^To.*(root@keg|root@scotch) +#$MAIL/runs +/dev/null + +### more cron mail +:0 +* ^From: root \$ +/dev/null + +:0 # postmaster mail, separate for easy deletion +* ^TO_(postmaster|daemon|csua-approval)(@[-a-z0-9.]+\.berkeley\.edu)?([,> ]|$) +/dev/null + + +#spam :( +#:0 HB +#* <256000 +#* !? /usr/local/bin/spamc -c +#$MAIL/spam +#/dev/null + +:0 +* ^Subject:.*[fF][cC][yY][iI].* +/dev/null + +:0 +* ^From:.*Mirza Party.* +/dev/null + +:0 +* ^From:.*solylunasf@yahoo.com.* +/dev/null + + +# root mail +:0: +* ^TO_root@ +$MAIL/root + +#:0: +#* ^TO_politburo@ +#* ^TO_officers@ +#$MAIL/politburo + +## windows-1251 +#:0 +#* ^Subject:.*windows-1251 +#$MAIL/spam + +#run spamass +#:0 fw +#| spamassassin + +:0 +* ^Subject:.*SPAM.XXX.* +/dev/null + +# de-HTML +:0 fbw +* ^Content-Type:[ ]*text/html +| lynx -dump -stdin \ +&& echo "" \ +&& echo "=================================================" \ +&& echo "This HTML message has been made into text by lynx" \ +&& echo "=================================================" + + +#:0 c +#| grep "^Subject" | cut -d ":" -f 2- | nc 10.42.0.7 10101 -q 1 + +:0 +* ^To.*barak@michener.com +$MAIL/michener.com + +:0 +* ^To.*bmichener@berkeley.edu +$MAIL/bmichener.berkeley + +:0 +* ^To.*ringhunters@yahoogroups.com +$MAIL/ringhunters + +:0 +$MAIL/misc + + + + + diff --git a/.screenrc b/.screenrc new file mode 100644 index 0000000..c78ad75 --- /dev/null +++ b/.screenrc @@ -0,0 +1,140 @@ +# $Id: screenrc,v 1.3 1998-06-15 20:06:42-07 mconst Exp mconst $ + +# make bells in other windows audible +bell "Bell in window %^G" + +# get rid of some useless stuff in /usr/local/etc/screenrc +bind P +bind R + +# add an easy key to renumber the current window +bind \# colon "number " + +# unbind the keys for "kill all windows" +bind \\ echo "You cannot hope to slay so many windows at once!" +register \\ ^A\ +bind ^\ process \\ + +# make h consistent with ^H as "move to previous window"; use C for hardcopy +bind h prev +bind C hardcopy + +# make ^N and ^P next and prev for laziness +bind ^N next +bind ^P prev + +# make "kill this window" a bit harder to hit +bind k echo "Your weak spell bounces harmlessly off the window." +bind K kill + +# unbind "toggle wrap mode" and flow control, which I tend to hit by mistake +bind r echo "Despite your effort, the wrap mode remains unchanged." +bind f echo "Despite your effort, the flow control remains unchanged." +register r ^Ar +register f ^Af +bind ^R process r +bind ^F process f + +# make split more convenient: it now brings up the previous window +# instead of a blank one, and it leaves the cursor in the new region +register S "^O:split^M^O^I^O^O" +bind S process S + +# bind generic function keys to switch windows +bindkey -k k0 select 9 +bindkey -k k1 select 0 +bindkey -k k2 select 1 +bindkey -k k3 select 2 +bindkey -k k4 select 3 +bindkey -k k5 select 4 +bindkey -k k6 select 5 +bindkey -k k7 select 6 +bindkey -k k8 select 7 +bindkey -k k9 select 8 +#bindkey -k k; select 0 + +bindkey "\033[[A" select 1 +bindkey "\033[[B" select 2 +bindkey "\033[[C" select 3 +bindkey "\033[[D" select 4 +bindkey "\033[[E" select 5 + +bindkey "\033[11~" select 1 +bindkey "\033[12~" select 2 +bindkey "\033[13~" select 3 +bindkey "\033[14~" select 4 +bindkey "\033[15~" select 5 +bindkey "\033[17~" select 6 +bindkey "\033[18~" select 7 +bindkey "\033[19~" select 8 +bindkey "\033[20~" select 9 +bindkey "\033[21~" select 0 + +bindkey "\033[11~" select 1 +bindkey "\033[12~" select 2 +bindkey "\033[13~" select 3 +bindkey "\033[14~" select 4 +bindkey "\033[15~" select 5 + +# make keypad_delete send ascii 127. this is wrong: really I ought +# to fix all the termcaps that have kD=\177 instead of kD=\E[3~, but +# this works and I don't care that much. +bindkey -k kD stuff \177 + +# by default, always let me know when background windows produce text +defmonitor on + +# don't lock up when one display dies +defnonblock on + +# keep 5000 lines of history in all windows +defscrollback 5000 + +# make ^O the escape character, and make ^Oo a literal ^O +#escape ^Oo + +# use the xterm's title bar to display window titles, but display ordinary +# screen messages on the bottom line, as usual +#hardstatus off +#hardstatus ignore + +# make the timeout for multicharacter key bindings nice and short +maptimeout 100 + +# let messages be displayed for a long time if they're not interrupted +msgwait 15 + +# use interesting messages +nethack on + +# use nifty cool dynamic window title updating +shelltitle "$ |bash" + +# by default, wait an entire minute before deciding a window is silent +silencewait 60 + +# suppress the default startup message +startup_message off + +# pretend to be a vt100, since no one has heard of terminal type "screen" +#term vt220 +term xterm-color + +# use an xterm's title bar to display the hardstatus line +termcapinfo xterm hs:ts=\E]0;:fs=\007:ds=\E]0;\007 + +# make bells in this window audible +vbell off + +# make only the first window show up in the utmp, and report idle time to it +#screen -t "] |login" 0 +#reportidle +#deflogin off +deflogin on + +#Add neato titlebar and windowlist. +hardstatus on +hardstatus alwayslastline +#caption always "%{= C}screen[%n] | %c | %h%=" +hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %D %m/%d %C%a " +windowlist string " screen[%n %t] %h" diff --git a/.vim/autoload/rubycomplete.vim b/.vim/autoload/rubycomplete.vim new file mode 100644 index 0000000..003dc0b --- /dev/null +++ b/.vim/autoload/rubycomplete.vim @@ -0,0 +1,530 @@ +" Vim completion script +" Language: Ruby +" Maintainer: Mark Guzman +" Info: $Id: rubycomplete.vim,v 1.33 2006/06/19 17:10:24 segy Exp $ +" Version: 0.6 +" URL: http://vim-ruby.rubyforge.org +" Anon CVS: See above site +" Release Coordinator: Doug Kearns +" ---------------------------------------------------------------------------- +" +" Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) +" ---------------------------------------------------------------------------- + +" {{{ requirement checks +if !has('ruby') + s:ErrMsg( "Error: Required vim compiled with +ruby" ) + finish +endif + +if version < 700 + s:ErrMsg( "Error: Required vim >= 7.0" ) + finish +endif +" }}} requirement checks + +if !exists("g:rubycomplete_rails") + let g:rubycomplete_rails = 0 +endif + +if !exists("g:rubycomplete_classes_in_global") + let g:rubycomplete_classes_in_global = 0 +endif + +if !exists("g:rubycomplete_buffer_loading") + let g:rubycomplete_classes_in_global = 0 +endif + + +" {{{ vim-side support functions +function! s:ErrMsg(msg) + echohl ErrorMsg + echo a:msg + echohl None +endfunction + +function! s:GetBufferRubyModule(name) + let [snum,enum] = s:GetBufferRubyEntity(a:name, "module") + return snum . '..' . enum +endfunction + +function! s:GetBufferRubyClass(name) + let [snum,enum] = s:GetBufferRubyEntity(a:name, "class") + return snum . '..' . enum +endfunction + +function! s:GetBufferRubySingletonMethods(name) +endfunction + +function! s:GetBufferRubyEntity( name, type ) + let stopline = 1 + let crex = '^\s*' . a:type . '\s*' . a:name . '\s*\(<\s*.*\s*\)\?\n*\(\(\s\|#\).*\n*\)*\n*\s*end$' + let [lnum,lcol] = searchpos( crex, 'nbw') + if lnum == 0 && lcol == 0 + return [0,0] + endif + + let [enum,ecol] = searchpos( crex, 'nebw') + if lnum > enum + let realdef = getline( lnum ) + let crexb = '^' . realdef . '\n*\(\(\s\|#\).*\n*\)*\n*\s*end$' + let [enum,ecol] = searchpos( crexb, 'necw' ) + endif + " we found a the class def + return [lnum,enum] +endfunction + +function! s:IsInClassDef() + let [snum,enum] = s:GetBufferRubyEntity( '.*', "class" ) + let ret = 'nil' + let pos = line('.') + + if snum < pos && pos < enum + let ret = snum . '..' . enum + endif + + return ret +endfunction + +function! s:GetRubyVarType(v) + let stopline = 1 + let vtp = '' + let pos = getpos('.') + let [lnum,lcol] = searchpos('^\s*#\s*@var\s*'.a:v.'\>\s\+[^ \t]\+\s*$','nb',stopline) + if lnum != 0 && lcol != 0 + call setpos('.',pos) + let str = getline(lnum) + let vtp = substitute(str,'^\s*#\s*@var\s*'.a:v.'\>\s\+\([^ \t]\+\)\s*$','\1','') + return vtp + endif + call setpos('.',pos) + if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1 + let ctors = '\(now\|new\|open\|get_instance\|find\|create\)' + else + let ctors = '\(now\|new\|open\|get_instance\)' + endif + + let [lnum,lcol] = searchpos(''.a:v.'\>\s*[+\-*/]*=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%r{\|[A-Za-z0-9@:\-()]\+...\?\)','nb',stopline) + if lnum != 0 && lcol != 0 + let str = matchstr(getline(lnum),'=\s*\([^ \t]\+.' . ctors . '\>\|[\[{"''/]\|%r{\|[A-Za-z0-9@:\-()]\+...\?\)',lcol) + let str = substitute(str,'^=\s*','','') + call setpos('.',pos) + if str == '"' || str == '''' + return 'String' + elseif str == '[' + return 'Array' + elseif str == '{' + return 'Hash' + elseif str == '/' || str == '%r{' + return 'Regexp' + elseif strlen(str) >= 4 && stridx(str,'..') != -1 + return 'Range' + elseif strlen(str) > 4 + let l = stridx(str,'.') + return str[0:l-1] + end + return '' + endif + call setpos('.',pos) + return '' +endfunction + +"}}} vim-side support functions + +function! rubycomplete#Complete(findstart, base) + "findstart = 1 when we need to get the text length + if a:findstart + let line = getline('.') + let idx = col('.') + while idx > 0 + let idx -= 1 + let c = line[idx-1] + if c =~ '\w' + continue + elseif ! c =~ '\.' + idx = -1 + break + else + break + endif + endwhile + + return idx + "findstart = 0 when we need to return the list of completions + else + let g:rubycomplete_completions = [] + execute "ruby get_completions('" . a:base . "')" + return g:rubycomplete_completions + endif +endfunction + + +function! s:DefRuby() +ruby << RUBYEOF +# {{{ ruby completion +RailsWords = [ + "has_many", "has_one", + "belongs_to", + ] + +ReservedWords = [ + "BEGIN", "END", + "alias", "and", + "begin", "break", + "case", "class", + "def", "defined", "do", + "else", "elsif", "end", "ensure", + "false", "for", + "if", "in", + "module", + "next", "nil", "not", + "or", + "redo", "rescue", "retry", "return", + "self", "super", + "then", "true", + "undef", "unless", "until", + "when", "while", + "yield", + ] + +Operators = [ "%", "&", "*", "**", "+", "-", "/", + "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>", + "[]", "[]=", "^", ] + + +def load_requires + buf = VIM::Buffer.current + enum = buf.line_number + nums = Range.new( 1, enum ) + nums.each do |x| + ln = buf[x] + begin + eval( "require %s" % $1 ) if /.*require\s*(.*)$/.match( ln ) + rescue Exception + #ignore? + end + end +end + +def load_buffer_class(name) + classdef = get_buffer_entity(name, 's:GetBufferRubyClass("%s")') + return if classdef == nil + + pare = /^\s*class\s*(.*)\s*<\s*(.*)\s*\n/.match( classdef ) + load_buffer_class( $2 ) if pare != nil + + mixre = /.*\n\s*include\s*(.*)\s*\n/.match( classdef ) + load_buffer_module( $2 ) if mixre != nil + + begin + eval classdef + rescue + VIM::evaluate( "s:ErrMsg( 'Problem loading class \"%s\", was it already completed?' )" % name ) + end +end + +def load_buffer_module(name) + classdef = get_buffer_entity(name, 's:GetBufferRubyModule("%s")') + return if classdef == nil + + begin + eval classdef + rescue + VIM::evaluate( "s:ErrMsg( 'Problem loading module \"%s\", was it already completed?' )" % name ) + end +end + +def get_buffer_entity(name, vimfun) + loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") + return nil if loading_allowed != '1' + return nil if /(\"|\')+/.match( name ) + buf = VIM::Buffer.current + nums = eval( VIM::evaluate( vimfun % name ) ) + return nil if nums == nil + return nil if nums.min == nums.max && nums.min == 0 + + cur_line = VIM::Buffer.current.line_number + classdef = "" + nums.each do |x| + if x != cur_line + ln = buf[x] + classdef += "%s\n" % ln + end + end + + return classdef +end + +def get_var_type( receiver ) + if /(\"|\')+/.match( receiver ) + "String" + else + VIM::evaluate("s:GetRubyVarType('%s')" % receiver) + end +end + +def get_buffer_classes() + # this will be a little expensive. + loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") + allow_aggressive_load = VIM::evaluate("exists('g:rubycomplete_classes_in_global') && g:rubycomplete_classes_in_global") + return [] if allow_aggressive_load != '1' || loading_allowed != '1' + + buf = VIM::Buffer.current + eob = buf.length + ret = [] + rg = 1..eob + + rg.each do |x| + if /^\s*class\s*([A-Za-z0-9_-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*/.match( buf[x] ) + ret.push $1 + end + end + + return ret +end + +def load_rails() + allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") + return if allow_rails != '1' + + buf_path = VIM::evaluate('expand("%:p")') + file_name = VIM::evaluate('expand("%:t")') + path = buf_path.gsub( file_name, '' ) + path.gsub!( /\\/, "/" ) + pup = [ "./", "../", "../../", "../../../", "../../../../" ] + pok = nil + + pup.each do |sup| + tpok = "%s%sconfig" % [ path, sup ] + if File.exists?( tpok ) + pok = tpok + break + end + end + + return if pok == nil + + bootfile = pok + "/boot.rb" + envfile = pok + "/environment.rb" + if File.exists?( bootfile ) && File.exists?( envfile ) + begin + require bootfile + require envfile + begin + require 'console_app' + require 'console_with_helpers' + rescue + # 1.0 + end + Rails::Initializer.run + VIM::command('let s:rubycomplete_rails_loaded = 1') + rescue + VIM::evaluate( "s:ErrMsg('Error loading rails environment')" ) + end + end +end + +def get_rails_helpers + allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") + rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') + return [] if allow_rails != '1' || rails_loaded != '1' + return RailsWords +end + +def add_rails_columns( cls ) + allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") + rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') + return [] if allow_rails != '1' || rails_loaded != '1' + eval( "#{cls}.establish_connection" ) + return [] unless eval( "#{cls}.ancestors.include?(ActiveRecord::Base).to_s" ) + col = eval( "#{cls}.column_names" ) + return col if col + return [] +end + +def clean_sel(sel, msg) + sel.delete_if { |x| x == nil } + sel.uniq! + sel.grep(/^#{Regexp.quote(msg)}/) if msg != nil +end + +def get_completions(base) + loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") + if loading_allowed == '1' + load_requires + load_rails + end + + input = VIM::Buffer.current.line + cpos = VIM::Window.current.cursor[1] - 1 + input = input[0..cpos] + input += base + input.sub!(/.*[ \t\n\"\\'`><=;|&{(]/, '') # Readline.basic_word_break_characters + input.sub!(/self\./, '') + + message = nil + receiver = nil + methods = [] + variables = [] + classes = [] + + case input + when /^(\/[^\/]*\/)\.([^.]*)$/ # Regexp + receiver = $1 + message = Regexp.quote($2) + methods = Regexp.instance_methods(true) + + when /^([^\]]*\])\.([^.]*)$/ # Array + receiver = $1 + message = Regexp.quote($2) + methods = Array.instance_methods(true) + + when /^([^\}]*\})\.([^.]*)$/ # Proc or Hash + receiver = $1 + message = Regexp.quote($2) + methods = Proc.instance_methods(true) | Hash.instance_methods(true) + + when /^(:[^:.]*)$/ # Symbol + if Symbol.respond_to?(:all_symbols) + receiver = $1 + message = $1.sub( /:/, '' ) + methods = Symbol.all_symbols.collect{|s| s.id2name} + methods.delete_if { |c| c.match( /'/ ) } + end + + when /^::([A-Z][^:\.\(]*)$/ # Absolute Constant or class methods + receiver = $1 + methods = Object.constants + methods.grep(/^#{receiver}/).collect{|e| "::" + e} + + when /^(((::)?[A-Z][^:.\(]*)+)::?([^:.]*)$/ # Constant or class methods + receiver = $1 + message = Regexp.quote($4) + begin + methods = eval("#{receiver}.constants | #{receiver}.methods") + rescue Exception + methods = [] + end + methods.grep(/^#{message}/).collect{|e| receiver + "::" + e} + + when /^(:[^:.]+)\.([^.]*)$/ # Symbol + receiver = $1 + message = Regexp.quote($2) + methods = Symbol.instance_methods(true) + + when /^([0-9_]+(\.[0-9_]+)?(e[0-9]+)?)\.([^.]*)$/ # Numeric + receiver = $1 + message = Regexp.quote($4) + begin + methods = eval(receiver).methods + rescue Exception + methods = [] + end + + when /^(\$[^.]*)$/ #global + methods = global_variables.grep(Regexp.new(Regexp.quote($1))) + + when /^((\.?[^.]+)+)\.([^.]*)$/ # variable + receiver = $1 + message = Regexp.quote($3) + load_buffer_class( receiver ) + + cv = eval("self.class.constants") + vartype = get_var_type( receiver ) + if vartype != '' + load_buffer_class( vartype ) + + begin + methods = eval("#{vartype}.instance_methods") + variables = eval("#{vartype}.instance_variables") + rescue Exception + end + elsif (cv).include?(receiver) + # foo.func and foo is local var. + methods = eval("#{receiver}.methods") + vartype = receiver + elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver + vartype = receiver + # Foo::Bar.func + begin + methods = eval("#{receiver}.methods") + rescue Exception + end + else + # func1.func2 + ObjectSpace.each_object(Module){|m| + next if m.name != "IRB::Context" and + /^(IRB|SLex|RubyLex|RubyToken)/ =~ m.name + methods.concat m.instance_methods(false) + } + end + variables += add_rails_columns( "#{vartype}" ) if vartype && vartype.length > 0 + + when /^\(?\s*[A-Za-z0-9:^@.%\/+*\(\)]+\.\.\.?[A-Za-z0-9:^@.%\/+*\(\)]+\s*\)?\.([^.]*)/ + message = $1 + methods = Range.instance_methods(true) + + when /^\.([^.]*)$/ # unknown(maybe String) + message = Regexp.quote($1) + methods = String.instance_methods(true) + + else + inclass = eval( VIM::evaluate("s:IsInClassDef()") ) + + if inclass != nil + classdef = "%s\n" % VIM::Buffer.current[ inclass.min ] + found = /^\s*class\s*([A-Za-z0-9_-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*\n$/.match( classdef ) + + if found != nil + receiver = $1 + message = input + load_buffer_class( receiver ) + begin + methods = eval( "#{receiver}.instance_methods" ) + methods += get_rails_helpers + variables += add_rails_columns( "#{receiver}" ) + rescue Exception + found = nil + end + end + end + + if inclass == nil || found == nil + classes = eval("self.class.constants") + classes += get_buffer_classes + message = receiver = input + end + end + + methods = clean_sel( methods, message ) + methods = (methods-Object.instance_methods) + variables = clean_sel( variables, message ) + classes = clean_sel( classes, message ) + valid = [] + valid += methods.collect { |m| { :name => m, :type => 'f' } } + valid += variables.collect { |v| { :name => v, :type => 'v' } } + valid += classes.collect { |c| { :name => c, :type => 't' } } + valid.sort! { |x,y| x[:name] <=> y[:name] } + + outp = "" + + rg = 0..valid.length + rg.step(150) do |x| + stpos = 0+x + enpos = 150+x + valid[stpos..enpos].each { |c| outp += "{'word':'%s','item':'%s','kind':'%s'}," % [ c[:name], c[:name], c[:type] ] } + outp.sub!(/,$/, '') + + VIM::command("call extend(g:rubycomplete_completions, [%s])" % outp) + outp = "" + end +end + +# }}} ruby completion +RUBYEOF +endfunction + +let s:rubycomplete_rails_loaded = 0 + +call s:DefRuby() +" vim:tw=78:sw=4:ts=8:et:fdm=marker:ft=vim:norl: diff --git a/.vim/charm.vim b/.vim/charm.vim new file mode 100644 index 0000000..38f2c89 --- /dev/null +++ b/.vim/charm.vim @@ -0,0 +1,18 @@ +fu! SendToCharm(subject,mood) + if a:subject == "" + let subject=input("Subject: ") + else + let subject=a:subject + endif + if a:mood == "" + let mood=input("Mood: ") + else + let mood=a:mood + endif + exe "w!" + exe "!cat % | charm -q -s \"".subject."\" -m \"".mood."\"" +endf + +if !exists(":PostToLJ") + command PostToLJ :call SendToCharm("","") +endif diff --git a/.vim/colors/.barak.vim.swp b/.vim/colors/.barak.vim.swp new file mode 100644 index 0000000..82c4652 Binary files /dev/null and b/.vim/colors/.barak.vim.swp differ diff --git a/.vim/colors/barak.vim b/.vim/colors/barak.vim new file mode 100644 index 0000000..98f9ba1 --- /dev/null +++ b/.vim/colors/barak.vim @@ -0,0 +1,99 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" File: "/home/michener/.vim/barak.vim" +" Version: 1.4 +" Created: "Sun Jul 30 23:54:41 PDT 2006" +" Updated: "Sun Jan 7 02:12:52 PST 2007" +" Copyright (C) 2006, Barak Michener +" Modified from colorscheme "dante": +" Copyright (C) 2002, Caciano Machado +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Colorscheme Option: +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +hi clear +if exists("syntax on") + syntax reset +endif +let g:colors_name = "barak" + +" General colors +hi Normal ctermfg=gray guifg=grey75 guibg=black +hi Directory term=bold ctermfg=blue guifg=royalblue +hi ErrorMsg term=standout ctermfg=white ctermbg=red guifg=white guibg=red3 +"hi NonText term=bold ctermfg=darkgray guibg=gray3 guifg=gray20 +hi NonText term=bold ctermfg=gray guibg=gray3 guifg=gray40 +hi SpecialKey term=bold ctermfg=darkgray guifg=gray30 +hi LineNr term=underline ctermfg=darkgray guifg=ivory4 guibg=gray4 +hi IncSearch term=reverse cterm=reverse gui=reverse,bold guifg=darkgoldenrod2 +hi Search term=reverse ctermfg=black ctermbg=yellow guifg=gray10 guibg=gold2 +hi Visual term=bold,reverse cterm=bold,reverse ctermfg=gray ctermbg=black gui=bold,reverse guifg=gray40 guibg=black +hi VisualNOS term=bold,underline cterm=bold,underline gui=bold,underline +hi MoreMsg term=bold ctermfg=green gui=bold guifg=olivedrab1 +hi ModeMsg term=bold ctermfg=red cterm=bold gui=bold guifg=red +hi Question term=standout ctermfg=green gui=bold guifg=olivedrab1 +hi WarningMsg term=standout ctermfg=red gui=bold guifg=red3 +hi WildMenu term=standout ctermfg=black ctermbg=yellow guifg=black guibg=gold2 +hi Folded term=standout ctermfg=blue ctermbg=white guifg=royalblue1 guibg=white +hi FoldColumn term=standout ctermfg=blue ctermbg=white guifg=royalblue3 guibg=white +hi DiffAdd term=bold ctermbg=blue guibg=royalblue2 +hi DiffChange term=bold ctermbg=darkmagenta guibg=maroon +hi DiffDelete term=bold cterm=bold ctermfg=lightblue ctermbg=cyan gui=bold guifg=lightblue guibg=cyan4 +hi DiffText term=reverse cterm=bold ctermbg=red gui=bold guibg=red3 +hi Cursor guifg=bg guibg=fg +hi lCursor guifg=bg guibg=fg +hi StatusLine term=reverse cterm=reverse gui=reverse guifg=gray60 +hi StatusLineNC term=reverse cterm=reverse gui=reverse guifg=gray40 +hi VertSplit term=reverse cterm=reverse gui=bold,reverse guifg=gray40 +hi Title term=bold ctermfg=magenta gui=bold guifg=aquamarine + +if version >= 700 + hi Pmenu ctermfg=white ctermbg=blue guifg=white guibg=MidnightBlue + hi PmenuSel ctermfg=darkblue ctermbg=white guibg=white guifg=MidnightBlue + hi PmenuSbar ctermfg=lightgray ctermbg=darkgray + hi PmenuThumb cterm=reverse + hi WildMenu term=standout ctermfg=white ctermbg=blue +endif + +" syntax hi colors +hi Comment term=bold ctermfg=darkgreen guifg=ForestGreen +hi PreProc term=underline ctermfg=darkmagenta guifg=magenta3 +hi Constant term=underline ctermfg=red guifg=firebrick3 +"hi Type term=underline ctermfg=darkcyan gui=none guifg=CadetBlue3 +hi Type term=underline ctermfg=darkcyan gui=none guifg=turquoise3 +hi Statement term=bold ctermfg=blue gui=none guifg=RoyalBlue1 +hi Identifier term=underline ctermfg=darkcyan guifg=DeepSkyBlue +hi Function ctermfg=darkcyan guifg=MediumPurple2 +hi Ignore term=bold ctermfg=darkgray gui=bold guifg=gray45 +hi Special term=underline ctermfg=brown guifg=khaki3 +hi Error term=reverse ctermfg=gray ctermbg=red guifg=gray guibg=red3 +hi Todo term=standout ctermfg=black ctermbg=yellow gui=bold guifg=gray10 guibg=yellow4 +hi Underlined term=underline cterm=underline ctermfg=blue gui=underline guifg=slateblue +hi Number term=underline ctermfg=darkyellow guifg=goldenrod1 +" syntax hi links +hi link String Constant +hi link Character Constant +hi link Number Constant +hi link Boolean Constant +hi link Float Number +"hi link Function Identifier +hi link Number Constant +hi link Conditional Statement +hi link Repeat Statement +hi link Label Statement +hi link Keyword Statement +hi link Exception Statement +hi link Operator Statement +hi link Include PreProc +hi link Define PreProc +hi link Macro PreProc +hi link PreCondit PreProc +"hi link StorageClass Type +hi link StorageClass Statement +"hi link Structure Type +hi link Structure Statement +hi link Typedef Type +hi link Tag Special +hi link SpecialChar Special +hi link Delimiter Special +hi link SpecialComment Special +hi link Debug Special +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/.vim/colors/dante.vim b/.vim/colors/dante.vim new file mode 100644 index 0000000..f584889 --- /dev/null +++ b/.vim/colors/dante.vim @@ -0,0 +1,83 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" File: "/home/caciano/.vim/dante.vim" +" Created: "Thu, 23 May 2002 00:12:20 -0300 (caciano)" +" Updated: "Sat, 24 Aug 2002 14:04:21 -0300 (caciano)" +" Copyright (C) 2002, Caciano Machado +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Colorscheme Option: +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +hi clear +if exists("syntax on") + syntax reset +endif +let g:colors_name = "dante" + +" General colors +hi Normal ctermfg=gray guifg=peachpuff3 guibg=black +hi Directory term=bold ctermfg=blue guifg=royalblue +hi ErrorMsg term=standout ctermfg=white ctermbg=red guifg=white guibg=red3 +hi NonText term=bold ctermfg=darkgray guibg=gray3 guifg=gray20 +hi SpecialKey term=bold ctermfg=darkgray guifg=gray30 +hi LineNr term=underline ctermfg=darkgray guifg=ivory4 guibg=gray4 +hi IncSearch term=reverse cterm=reverse gui=reverse,bold guifg=darkgoldenrod2 +hi Search term=reverse ctermfg=black ctermbg=yellow guifg=gray10 guibg=gold2 +hi Visual term=bold,reverse cterm=bold,reverse ctermfg=gray ctermbg=black gui=bold,reverse guifg=gray40 guibg=black +hi VisualNOS term=bold,underline cterm=bold,underline gui=bold,underline +hi MoreMsg term=bold ctermfg=green gui=bold guifg=olivedrab1 +hi ModeMsg term=bold cterm=bold gui=bold +hi Question term=standout ctermfg=green gui=bold guifg=olivedrab1 +hi WarningMsg term=standout ctermfg=red gui=bold guifg=red3 +hi WildMenu term=standout ctermfg=black ctermbg=yellow guifg=black guibg=gold2 +hi Folded term=standout ctermfg=blue ctermbg=white guifg=royalblue1 guibg=white +hi FoldColumn term=standout ctermfg=blue ctermbg=white guifg=royalblue3 guibg=white +hi DiffAdd term=bold ctermbg=blue guibg=royalblue2 +hi DiffChange term=bold ctermbg=darkmagenta guibg=maroon +hi DiffDelete term=bold cterm=bold ctermfg=lightblue ctermbg=cyan gui=bold guifg=lightblue guibg=cyan4 +hi DiffText term=reverse cterm=bold ctermbg=red gui=bold guibg=red3 +hi Cursor guifg=bg guibg=fg +hi lCursor guifg=bg guibg=fg +hi StatusLine term=reverse cterm=reverse gui=reverse guifg=gray60 +hi StatusLineNC term=reverse cterm=reverse gui=reverse guifg=gray40 +hi VertSplit term=reverse cterm=reverse gui=bold,reverse guifg=gray40 +hi Title term=bold ctermfg=magenta gui=bold guifg=aquamarine + +" syntax hi colors +hi Comment term=bold ctermfg=darkcyan guifg=cyan4 +hi PreProc term=underline ctermfg=darkblue guifg=dodgerblue4 +hi Constant term=underline ctermfg=darkred guifg=firebrick3 +hi Type term=underline ctermfg=darkgreen gui=none guifg=chartreuse3 +hi Statement term=bold ctermfg=darkyellow gui=none guifg=gold3 +hi Identifier term=underline ctermfg=darkgreen guifg=darkolivegreen4 +hi Ignore term=bold ctermfg=darkgray guifg=gray45 +hi Special term=underline ctermfg=brown guifg=sienna +hi Error term=reverse ctermfg=gray ctermbg=red guifg=gray guibg=red3 +hi Todo term=standout ctermfg=black ctermbg=yellow gui=bold guifg=gray10 guibg=yellow4 +hi Underlined term=underline cterm=underline ctermfg=darkblue gui=underline guifg=slateblue +hi Number term=underline ctermfg=darkred guifg=red2 +" syntax hi links +hi link String Constant +hi link Character Constant +hi link Number Constant +hi link Boolean Constant +hi link Float Number +hi link Function Identifier +hi link Number Constant +hi link Conditional Statement +hi link Repeat Statement +hi link Label Statement +hi link Keyword Statement +hi link Exception Statement +hi link Operator Statement +hi link Include PreProc +hi link Define PreProc +hi link Macro PreProc +hi link PreCondit PreProc +hi link StorageClass Type +hi link Structure Type +hi link Typedef Type +hi link Tag Special +hi link SpecialChar Special +hi link Delimiter Special +hi link SpecialComment Special +hi link Debug Special +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/.vim/colors/ps_color.vim b/.vim/colors/ps_color.vim new file mode 100644 index 0000000..fb3e02b --- /dev/null +++ b/.vim/colors/ps_color.vim @@ -0,0 +1,469 @@ +" Vim colour file --- PSC +" Maintainer: Pan, Shi Zhu +" URL: http://vim.sourceforge.net/scripts/script.php?script_id=760 +" Last Change: 18 July 2006 +" Version: 2.9 +" +" Please prepend [VIM] in the title when writing e-mail to me, or it will +" be automatically treated as spam and removed. +" +" See the help document for all details, the help document will be +" installed after the script has been sourced once, do not open the +" script when you source it for the first time. +" + +" Initializations: {{{1 +" + +" without user_commands, all these are not possible +if !has("user_commands") + finish +end + +function! s:init_option(var, value) + if !exists("g:psc_".a:var) + execute "let s:".a:var." = ".a:value + else + let s:{a:var} = g:psc_{a:var} + endif +endfunction +command! -nargs=+ InitOpt call s:init_option() + +function! s:multi_hi(setting, ...) + let l:idx = a:0 + while l:idx > 0 + let l:hlgroup = a:{l:idx} + execute "highlight ".l:hlgroup." ".a:setting + let l:idx = l:idx - 1 + endwhile +endfunction +command! -nargs=+ MultiHi call s:multi_hi() + +InitOpt style 'cool' +InitOpt inversed_todo 0 +InitOpt use_default_for_cterm 0 +InitOpt statement_different_from_type 0 +if s:style == 'warm' + InitOpt fontface 'mixed' +else + InitOpt fontface 'plain' +endif + +if !has("gui_running") + call s:init_option("cterm_style", "'".s:style."'") + + " Forces 'cool' style when gui is not present Since the 'warm' style for + " terminal isn't available now, and probably never will be. + if s:cterm_style=='warm' | let s:cterm_style = 'cool' + endif + if s:use_default_for_cterm==1 | let s:cterm_style = 'default' + elseif s:use_default_for_cterm==2 | let s:cterm_style = 'defdark' + endif +endif + + +InitOpt other_style 0 + +if has("gui_running") + if s:style=='warm' || s:style=='default' + set background=light + elseif s:style=='cool' || s:style=='defdark' + set background=dark + else | let s:other_style = 1 + endif +else + if s:cterm_style=='cool' || s:cterm_style=='defdark' + set background=dark + elseif s:cterm_style=='default' + set background=light + else | let s:other_style = 1 + endif +endif + + +highlight clear + +if exists("syntax_on") + syntax reset +endif + +let s:color_name = expand(":t:r") + +if s:other_style==0 | let g:colors_name = s:color_name + " Go from console version to gui, the color scheme should be sourced again + execute "autocmd TermChanged * if g:colors_name == '".s:color_name."' | " + \."colo ".s:color_name." | endif" +else + execute "runtime colors/".s:style.".vim" +endif + +" Command to go different schemes easier. +execute "command! -nargs=1 Colo if '".s:color_name."'!=\"\" | " + \'let g:psc_style = ""| endif | colo '.s:color_name + +" Give control to 'reloaded' scheme if possible +if s:style == 'reloaded' + finish +endif + +" }}}1 + +" Relevant Help: +" :h highlight-groups +" :h psc-cterm-color-table +" :ru syntax/hitest.vim +" +" Hardcoded Colors Comment: +" #aabbcc = Red aa, Green bb, Blue cc +" we must use hard-coded colours to get more 'tender' colours +" + + +" GUI: +" +" I don't want to abuse folding, but here folding is used to avoid confusion. +if s:style=='warm' + " Warm style for gui here {{{2 + " LIGHT COLOR DEFINE START + + highlight Normal guifg=#000000 guibg=#e0e0e0 + highlight Search guifg=#902000 guibg=#f8f8f8 + highlight Visual guifg=fg guibg=#a6caf0 + highlight Cursor guifg=#f0f0f0 guibg=#008000 + " The idea of CursorIM is pretty good, however, the feature is still buggy + " in the current version (Vim 7.0). + " The following line will be kept commented until the bug fixed. + " + " highlight CursorIM guifg=#f0f0f0 guibg=#800080 + highlight Special guifg=#907000 guibg=bg + highlight Comment guifg=#606000 guibg=bg + highlight Number guifg=#907000 guibg=bg + highlight Constant guifg=#007068 guibg=bg + highlight StatusLine guifg=fg guibg=#a6caf0 + highlight LineNr guifg=#686868 guibg=bg + highlight Question guifg=fg guibg=#d0d090 + highlight PreProc guifg=#009030 guibg=bg + if s:statement_different_from_type==1 + highlight Statement guifg=#4020a0 guibg=bg + else + highlight Statement guifg=#2060a8 guibg=bg + endif + highlight Type guifg=#0850a0 guibg=bg + if s:inversed_todo==1 + highlight Todo guifg=#e0e090 guibg=#000080 + else + highlight Todo guifg=#800000 guibg=#e0e090 + endif + " NOTE THIS IS IN THE WARM SECTION + highlight Error guifg=#c03000 guibg=bg + highlight Identifier guifg=#a030a0 guibg=bg + highlight ModeMsg guifg=fg guibg=#b0b0e0 + highlight VisualNOS guifg=fg guibg=#b0b0e0 + highlight SpecialKey guifg=#1050a0 guibg=bg + highlight NonText guifg=#002090 guibg=#d0d0d0 + highlight Directory guifg=#a030a0 guibg=bg + highlight ErrorMsg guifg=fg guibg=#f0b090 + highlight MoreMsg guifg=#489000 guibg=bg + highlight Title guifg=#a030a0 guibg=bg + highlight WarningMsg guifg=#b02000 guibg=bg + highlight WildMenu guifg=fg guibg=#d0d090 + highlight Folded guifg=fg guibg=#b0e0b0 + highlight FoldColumn guifg=fg guibg=#90e090 + highlight DiffAdd guifg=fg guibg=#b0b0e0 + highlight DiffChange guifg=fg guibg=#e0b0e0 + highlight DiffDelete guifg=#002090 guibg=#d0d0d0 + highlight DiffText guifg=fg guibg=#c0e080 + highlight SignColumn guifg=fg guibg=#90e090 + highlight IncSearch guifg=#f0f0f0 guibg=#806060 + highlight StatusLineNC guifg=fg guibg=#c0c0c0 + highlight VertSplit guifg=fg guibg=#c0c0c0 + highlight Underlined guifg=#6a5acd guibg=bg gui=underline + highlight Ignore guifg=bg guibg=bg + " NOTE THIS IS IN THE WARM SECTION + if v:version >= 700 + highlight SpellBad guifg=NONE guibg=NONE guisp=#c03000 + highlight SpellCap guifg=NONE guibg=NONE guisp=#2060a8 + highlight SpellRare guifg=NONE guibg=NONE guisp=#a030a0 + highlight SpellLocal guifg=NONE guibg=NONE guisp=#007068 + highlight Pmenu guifg=fg guibg=#e0b0e0 + highlight PmenuSel guifg=#f0f0f0 guibg=#806060 + highlight PmenuSbar guifg=fg guibg=#c0c0c0 + highlight PmenuThumb guifg=fg guibg=#c0e080 + highlight TabLine guifg=fg guibg=#c0c0c0 gui=underline + highlight TabLineFill guifg=fg guibg=#c0c0c0 gui=underline + highlight TabLineSel guifg=fg guibg=bg + highlight CursorColumn guifg=NONE guibg=#f0b090 + highlight CursorLine guifg=NONE guibg=NONE gui=underline + highlight MatchParen guifg=NONE guibg=#c0e080 + endif + + " LIGHT COLOR DEFINE END + " }}}2 +elseif s:style=='cool' + " Cool style for gui here {{{2 + " DARK COLOR DEFINE START + + highlight Normal guifg=#d0d0d0 guibg=#202020 + highlight Comment guifg=#d0d090 guibg=bg + highlight Constant guifg=#80c0e0 guibg=bg + highlight Number guifg=#e0c060 guibg=bg + highlight Identifier guifg=#f0c0f0 guibg=bg + if s:statement_different_from_type==1 + highlight Statement guifg=#98a8f0 guibg=bg + else + highlight Statement guifg=#c0d8f8 guibg=bg + endif + highlight PreProc guifg=#60f080 guibg=bg + highlight Type guifg=#b0d0f0 guibg=bg + highlight Special guifg=#e0c060 guibg=bg + highlight Error guifg=#f08060 guibg=bg + if s:inversed_todo==1 + highlight Todo guifg=#d0d090 guibg=#000080 + else + highlight Todo guifg=#800000 guibg=#d0d090 + endif + highlight Search guifg=#e0e0e0 guibg=#800000 + highlight Visual guifg=#000000 guibg=#a6caf0 + highlight Cursor guifg=#000000 guibg=#00f000 + " NOTE THIS IS IN THE COOL SECTION + " highlight CursorIM guifg=#000000 guibg=#f000f0 + highlight StatusLine guifg=#000000 guibg=#a6caf0 + highlight LineNr guifg=#b0b0b0 guibg=bg + highlight Question guifg=#000000 guibg=#d0d090 + highlight ModeMsg guifg=fg guibg=#000080 + highlight VisualNOS guifg=fg guibg=#000080 + highlight SpecialKey guifg=#b0d0f0 guibg=bg + highlight NonText guifg=#6080f0 guibg=#101010 + highlight Directory guifg=#80c0e0 guibg=bg + highlight ErrorMsg guifg=#d0d090 guibg=#800000 + highlight MoreMsg guifg=#c0e080 guibg=bg + highlight Title guifg=#f0c0f0 guibg=bg + highlight WarningMsg guifg=#f08060 guibg=bg + highlight WildMenu guifg=#000000 guibg=#d0d090 + highlight Folded guifg=#d0d0d0 guibg=#004000 + highlight FoldColumn guifg=#e0e0e0 guibg=#008000 + highlight DiffAdd guifg=fg guibg=#000080 + highlight DiffChange guifg=fg guibg=#800080 + highlight DiffDelete guifg=#6080f0 guibg=#202020 + highlight DiffText guifg=#000000 guibg=#c0e080 + highlight SignColumn guifg=#e0e0e0 guibg=#008000 + highlight IncSearch guifg=#000000 guibg=#d0d0d0 + highlight StatusLineNC guifg=#000000 guibg=#c0c0c0 + highlight VertSplit guifg=#000000 guibg=#c0c0c0 + highlight Underlined guifg=#80a0ff guibg=bg gui=underline + highlight Ignore guifg=#000000 guibg=bg + " NOTE THIS IS IN THE COOL SECTION + if v:version >= 700 + highlight SpellBad guifg=NONE guibg=NONE guisp=#f08060 + highlight SpellCap guifg=NONE guibg=NONE guisp=#6080f0 + highlight SpellRare guifg=NONE guibg=NONE guisp=#f0c0f0 + highlight SpellLocal guifg=NONE guibg=NONE guisp=#c0d8f8 + highlight Pmenu guifg=fg guibg=#800080 + highlight PmenuSel guifg=#000000 guibg=#d0d0d0 + highlight PmenuSbar guifg=fg guibg=#000080 + highlight PmenuThumb guifg=fg guibg=#008000 + highlight TabLine guifg=fg guibg=#008000 gui=underline + highlight TabLineFill guifg=fg guibg=#008000 gui=underline + highlight TabLineSel guifg=fg guibg=bg + highlight CursorColumn guifg=NONE guibg=#800000 + highlight CursorLine guifg=NONE guibg=NONE gui=underline + highlight MatchParen guifg=NONE guibg=#800080 + endif + + " DARK COLOR DEFINE END + " }}}2 +elseif s:style=='defdark' + highlight Normal guifg=#f0f0f0 guibg=#000000 +endif + +" Take NT gui for example, If you want to use a console font such as +" Lucida_Console with font size larger than 14, the font looks already thick, +" and the bold font for that will be too thick, you may not want it be bolded. +" The following code does this. +" +" All of the bold font may be disabled, since continuously switching between +" bold and plain font hurts consistency and will inevitably fatigue your eye! + +" Maximum 20 parameters for vim script function +" +MultiHi gui=NONE ModeMsg Search Cursor Special Comment Constant Number LineNr Question PreProc Statement Type Todo Error Identifier Normal + +MultiHi gui=NONE VisualNOS SpecialKey NonText Directory ErrorMsg MoreMsg Title WarningMsg WildMenu Folded FoldColumn DiffAdd DiffChange DiffDelete DiffText SignColumn + +" Vim 7 added stuffs +if v:version >= 700 + MultiHi gui=NONE Ignore PmenuSel PmenuSel PmenuSbar PmenuThumb TabLine TabLineFill TabLineSel + + " the gui=undercurl guisp could only support in Vim 7 + MultiHi gui=undercurl SpellBad SpellCap SpellRare SpellLocal + if s:style=="cool" || s:style=="warm" + MultiHi gui=underline TabLine TabLineFill Underlined CursorLine + else + MultiHi gui=underline TabLine Underlined + endif +endif + +" For reversed stuffs +MultiHi gui=NONE IncSearch StatusLine StatusLineNC VertSplit Visual + +if s:style=="cool" || s:style=="warm" + if s:fontface=="mixed" + MultiHi gui=bold IncSearch StatusLine StatusLineNC VertSplit Visual + endif +else + if s:fontface=="mixed" + hi StatusLine gui=bold,reverse + else + hi StatusLine gui=reverse + endif + MultiHi gui=reverse IncSearch StatusLineNC VertSplit Visual +endif + +" Enable the bold style +if s:fontface=="mixed" + MultiHi gui=bold Question DiffText Statement Type MoreMsg ModeMsg NonText Title VisualNOS DiffDelete TabLineSel +endif + + + + +" Color Term: + +" It's not quite possible to support 'cool' and 'warm' simultaneously, since +" we cannot expect a terminal to have more than 16 color names. +" + +" I assume Vim will never go to cterm mode when has("gui_running") returns 1, +" Please enlighten me if I am wrong. +" +if !has('gui_running') + " cterm settings {{{1 + if s:cterm_style=='cool' + + highlight Normal ctermfg=LightGrey ctermbg=Black + highlight Search ctermfg=White ctermbg=DarkRed + highlight Visual ctermfg=Black ctermbg=DarkCyan + highlight Cursor ctermfg=Black ctermbg=Green + highlight Special ctermfg=Yellow ctermbg=Black + highlight Comment ctermfg=DarkYellow ctermbg=Black + highlight Constant ctermfg=Blue ctermbg=Black + highlight Number ctermfg=Yellow ctermbg=Black + highlight StatusLine ctermfg=Black ctermbg=DarkCyan + highlight LineNr ctermfg=DarkGrey ctermbg=Black + highlight Question ctermfg=Black ctermbg=DarkYellow + highlight PreProc ctermfg=Green ctermbg=Black + highlight Statement ctermfg=Cyan ctermbg=Black + highlight Type ctermfg=Cyan ctermbg=Black + if s:inversed_todo==0 + highlight Todo ctermfg=DarkRed ctermbg=DarkYellow + else + highlight Todo ctermfg=DarkYellow ctermbg=DarkBlue + endif + highlight Error ctermfg=Red ctermbg=Black + highlight Identifier ctermfg=Magenta ctermbg=Black + highlight Folded ctermfg=White ctermbg=DarkGreen + highlight ModeMsg ctermfg=Grey ctermbg=DarkBlue + highlight VisualNOS ctermfg=Grey ctermbg=DarkBlue + highlight SpecialKey ctermfg=Cyan ctermbg=Black + highlight NonText ctermfg=Blue ctermbg=Black + highlight Directory ctermfg=Blue ctermbg=Black + highlight ErrorMsg ctermfg=DarkYellow ctermbg=DarkRed + highlight MoreMsg ctermfg=Green ctermbg=Black + highlight Title ctermfg=Magenta ctermbg=Black + highlight WarningMsg ctermfg=Red ctermbg=Black + highlight WildMenu ctermfg=Black ctermbg=DarkYellow + highlight FoldColumn ctermfg=White ctermbg=DarkGreen + highlight SignColumn ctermfg=White ctermbg=DarkGreen + highlight DiffText ctermfg=Black ctermbg=DarkYellow + highlight DiffDelete ctermfg=Blue ctermbg=Black + + if v:version >= 700 + highlight SpellBad ctermfg=NONE ctermbg=DarkRed + highlight SpellCap ctermfg=NONE ctermbg=DarkBlue + highlight SpellRare ctermfg=NONE ctermbg=DarkMagenta + highlight SpellLocal ctermfg=NONE ctermbg=DarkGreen + highlight Pmenu ctermfg=fg ctermbg=DarkMagenta + highlight PmenuSel ctermfg=bg ctermbg=fg + highlight PmenuSbar ctermfg=fg ctermbg=DarkBlue + highlight PmenuThumb ctermfg=fg ctermbg=DarkGreen + highlight TabLine ctermfg=fg ctermbg=DarkGreen cterm=underline + highlight TabLineFill ctermfg=fg ctermbg=DarkGreen cterm=underline + highlight TabLineSel ctermfg=fg ctermbg=bg + highlight CursorColumn ctermfg=NONE ctermbg=DarkRed + highlight CursorLine ctermfg=NONE ctermbg=NONE cterm=underline + highlight MatchParen ctermfg=NONE ctermbg=DarkMagenta + endif + if &t_Co==8 + " 8 colour terminal support, this assumes 16 colour is available through + " setting the 'bold' attribute, will get bright foreground colour. + " However, the bright background color is not available for 8-color terms. + " + " You can manually set t_Co=16 in your .vimrc to see if your terminal + " supports 16 colours, + MultiHi cterm=none DiffText Visual Cursor Comment Todo StatusLine Question DiffChange ModeMsg VisualNOS ErrorMsg WildMenu DiffAdd Folded DiffDelete Normal PmenuThumb + MultiHi cterm=bold Search Special Constant Number LineNr PreProc Statement Type Error Identifier SpecialKey NonText MoreMsg Title WarningMsg FoldColumn SignColumn Directory DiffDelete + + else + " Background > 7 is only available with 16 or more colors + + " Only use the s:fontface option when there is 16-colour(or more) + " terminal support + + MultiHi cterm=none WarningMsg Search Visual Cursor Special Comment Constant Number LineNr PreProc Todo Error Identifier Folded SpecialKey Directory ErrorMsg Normal PmenuThumb + MultiHi cterm=none WildMenu FoldColumn SignColumn DiffAdd DiffChange Question StatusLine DiffText + MultiHi cterm=reverse IncSearch StatusLineNC VertSplit + + " Well, well, bold font with color 0-7 is not possible. + " So, the Question, StatusLine, DiffText cannot act as expected. + + call s:multi_hi("cterm=".((s:fontface=="plain") ? "none" : "bold"), "Statement", "Type", "MoreMsg", "ModeMsg", "NonText", "Title", "VisualNOS", "DiffDelete", "TabLineSel") + + endif + + elseif s:cterm_style=='defdark' + highlight Normal ctermfg=LightGrey ctermbg=Black + endif + " }}}1 +endif + + +" Term: +" For console with only 4 colours (term, not cterm), we'll use the default. +" ... +" The default colorscheme is good enough for terms with no more than 4 colours +" + + +" Links: +" +if (s:style=='cool') || (s:style == 'warm') + " COLOR LINKS DEFINE START + + highlight link String Constant + " Character must be different from strings because in many languages + " (especially C, C++) a 'char' variable is scalar while 'string' is pointer, + " mistaken a 'char' for a 'string' will cause disaster! + highlight link Character Number + highlight link SpecialChar LineNr + highlight link Tag Identifier + " The following are not standard hi links, + " these are used by DrChip + highlight link Warning MoreMsg + highlight link Notice Constant + " these are used by Calendar + highlight link CalToday PreProc + " these are used by TagList + highlight link MyTagListTagName IncSearch + highlight link MyTagListTagScope Constant + + " COLOR LINKS DEFINE END +endif + + +" Clean: +" +delcommand InitOpt +delcommand MultiHi + +" vim:et:nosta:sw=2:ts=8: +" vim600:fdm=marker:fdl=1: diff --git a/.vim/doc/ps_color.txt b/.vim/doc/ps_color.txt new file mode 100644 index 0000000..158dd57 --- /dev/null +++ b/.vim/doc/ps_color.txt @@ -0,0 +1,603 @@ +*ps_color.txt* PSC For Vim version 7.0 Last change: 18 July 2006 + + +PERSONAL COLOUR SWITCHER *ps_colour* *pscolor* + + +Author: Pan, Shi Zhu. + +============================================================================== +CONTENTS *psc* *psc-contents* + + 1. Contents.....................|psc-contents| + 2. PSC Overview.................|psc-overview| + 3. PSC Installation.............|psc-usage| + 4. PSC Options..................|psc-options| + 5. PSC under color term ........|psc-cterm| + 6. PSC FAQ and Tips ............|psc-faq| + 7. PSC Release notes............|psc-release-notes| + 8. PSC Todo List................|psc-todo| + +For release notes, please see the header of ps_color.vim + +============================================================================== +PSC FEATURES OVERVIEW *psc-features* *psc-overview* + + Features ~ + + . PSC is firstly a color scheme which have both dark and light + background styles. + . It can have the same appearance in [cterm] as in [gui]. + . It is designed with gentle color to minimize fatigue of eye. + . It also works with other color schemes. + . Default foreground and background can easily be changed, it is more + configurable than most other color schemes + . Works with the optional tool reloaded.vim, can change the whole + color scheme in Hue,Saturation,Luminance color space. + + Design Concern ~ + + At the first glance this color scheme may look pretty 'dull', don't be + afraid, this is quite normal. Bear in mind that a text editor is not + a photo album, if a text editor looks exciting you may not be able to + stare at it for a long time. + + Predefined Vim Syntax highlighting can be too colorful or contrasty so + that many programmers prefer to switch off the syntax highlighting at + work. That is not a good idea because you will lost the advantages of + syntax high-lighting. It is often the case that we have to work for + 300+ minutes, then I decide to do-it-myself. + + Many user-defined color schemes in vim.sf.net tend to achieve low + contrast by having a strong color-cast, i.e. looks blueish or + yellowish or reddish. This does look comfortable at first, however, + any type of color-cast will cause the eyes less sensitive for + particular color after a long-time work session, and that's no good to + health. + + Efforts had been made to ensure no color-cast for this scheme, all + elementary colors like RGB and CYMK are evenly used. Like TeX, + 'consistency' is the principle this color scheme based on. Default + values which hurt consistency are amended according to the vim script + syntax/hitest.vim + + There are 3 parameters to describe a color: Hue, Saturation and + Brightness. In this color scheme, the saturation is low and the + brightness are designed to be very close to each other in order not to + fatigue our eyes after a whole day's programming work. + + Portability ~ + + Different monitor settings led to different look. In this color + scheme, it is assumed that the monitor adjust at 6500k color + temperature with a good gamma curve. If you have a 9300k monitor or + if the gamma curve is not optimal, the appearance may be less + comfortable, use adobe gamma loader or similar tools to adjust + your monitor if your monitor do not have the option to change color + temperature and/or gamma curve. + + Needless to say, VI is an editor originally designed to do edit tasks + in a text terminal, and VIM is an improved version of VI. Its a shame + that a color scheme cannot have a satisfactory appearance in cterm. + The cterm compatibility should be considered high priority when + designing ViM color scheme. + + I had made much attempt to make support for 8-color terminals, + however, 8 colors is not enough to represent a color scheme. Finally + I end up making the cterm support for 16-color terminal. Have to say + sorry if the color scheme sucks in your 8-color terminal, I had tried + my best. More details about cterm please see |psc-cterm|. + + *psc-about-background* + About the Background ~ + + We have talked about off-white backgrounds, any background which is + not black, grey or white should be changed constantly in order not to + make the eyes less sensitive to particular color. i.e. you can use + blue background on Monday, red background on Tuesday, green background + on Wednesday, but if you use blue background everyday, that's no good + to your health. + + Now we talk about the brightness of the background. Why dark + background is preferred over others? There are many reasons, such as, + the monitor emits lower radiation for black background. You may have + lots of similar reasons... + + But I'll talk about something you may not know: +> + It is easier to distinguish foreground colors on a dark background + than on a light background. + + At the same time, it is easier to distinguish background colors on + a light background than on a dark background. + + We will mainly change foreground colors for syntax highlighting. +< + Hence, we can reduce the contrast and saturation of the color in + a dark-background scheme, while retain the readability. Schemes with + white background usually comes with higher contrast and saturation. + This is probably the most important reason that the color scheme is + designed to be dark-background instead of light one. + + Now we came to know, that change the foreground color is enough to + emphasis text in a dark background, while for a white background, we + need to change the font shape (bold or italic, etc.), or change the + background color to effectively emphasis the text. This is probably + the reason Vim default scheme has bold properties for highlighting + groups, because the default scheme is a light background one. + + No one knows what color scheme is best for you, except yourself. Try! + +============================================================================== +PSC INSTALLATION *psc-usage* + + Step 1, Enable the color scheme ~ + + To use PSC is simple, just put ps_color.vim into your + [runtimepath]/colors and append the line > + + colorscheme ps_color +< + to your |.vimrc|. The [runtimepath] can be any directory listed in + |vimfiles|, normally your $HOME/.vim in Unix or $HOME/vimfiles in + Windows. + + Step 2, Install the help document ~ + + The help document will be automatically installed when the colorscheme + be sourced the first time. If it is not, type :colo ps_color now. + + After successfully installed the help document, you can use > + + :help psc-options +< + to go to the following section. + +============================================================================== +PSC OPTIONS *psc-options* + + You can let these options in your ~/.vimrc, most options works for + both GUI and cterm, only some of them do not work for both. + + Options set using the 'let' command must present [BEFORE] the color + scheme been sourced. + + *psc_style* + Style ~ +> + let psc_style='cool' + let psc_style='warm' + let psc_style='default' + let psc_style='defdark' +< + This selects between styles of colors, + The 'cool' is the default, dark background. + The 'warm' is the alternative, light background scheme. + + See |psc-about-background| for more knowledge about the background, + and the differences of two style. + + The 'default' and 'defdark' refers to Vim system default color scheme. + Which are provided only for reference. + + Let psc_style to any string other than the above 4 will switch to the + specified color scheme. For example, let psc_style='desert' and then + activate the ps_color, the color scheme will be chosen according to + desert.vim color scheme. + + *psc_cterm_style* + Color Term Style ~ +> + let psc_cterm_style='cool' +< + This is exactly the same to psc_style, except that it only affects the + console version of vim in a color terminal, the 'warm' is not + available for cterm. + By default, it will be set to the same value as 'psc_style'. You can + change it if you want different style in cterm from gui. + + + *psc_fontface* + Font face ~ +> + let psc_fontface='plain' + let psc_fontface='mixed' +< + The Vim default behavior is the 'mixed', however, the mixed font style + in a dark colorscheme is not optimal. This color uses 'plain' for + 'cool' style, i.e. No texts are bolded font. For 'warm', the default + is still 'mixed', If you want the mixed style in which the highlighted + statements are bolded font, choose this. If you want all texts be + bolded, choose 'plain' and specify a bolded guifont or terminal font. + + In GUI, this option also works for other color schemes. You can + disable the bold font and use your favorite color scheme. See + |psc-faq-ffothers| for detail. + + *psc_inversed_todo* + Inversed Todo ~ +> + let psc_inversed_todo=1 +< + When set to 1, the TODO group will be dark background with light font, + Otherwise, the TODO group have light background with dark foreground. + Default is 0. + + *psc_use_default_for_cterm* + Use default for cterm (obsoleted)~ + + This option is Obsoleted, retained only for backward compatibility, + see |psc_cterm_style| for alternative. + + *psc_statement_different_from_type* + Statement different from type ~ +> + let psc_statement_different_from_type=1 +< + The Statement-group and Type-group are easy to distinguish, different + color for them are not necessary, I use similar color for S-group + & T-group in order not to make the screen too 'colorful', also this + saves a color name for cterm. But if you do want the Statement & Type + to be different color, try 'let statement_different_from_type=1' in + your .vimrc file, which is available only for GUI. Since the color + names in cterm is limited to 16 we cannot have too many different + colors in cterm. + Default is 0, i.e. they have very similar color. + + *psc-change-background* + Changing the Background color ~ + + You may prefer a black background over the dark one, and it is + possible to customize it, this may make life more interesting. To do + this is quite straight forward for GUI, just define the Normal + highlight in your .gvimrc, [AFTER] the color scheme has been sourced. + + For example: +> + highlight Normal guibg=#000000 +< + The #103040 will give a taste similar to oceandeep, #152535 for + hhazure, #303030 for desert, #404040 for zenburn... Replace #103040 + with any color you like. You can do the same to guifg foreground if + you are careful enough, remember this is only possible for GUI. + + You can do this to the NonText group also, for example. +> + highlight NonText guibg=#202020 +< + will give you a taste similar to most color schemes on vim.sf.net, in + which the NonText has a different background than Normal text. + However, this is only useful in GUI, in cterm, there are only + 8 background colors, so it is wise not to have a different color. + + If you want more variations, please try the optional utility + reloaded.vim, this optional utility provides an amazing level of + customization. + + Quick switching between warm and cold styles ~ + + Here is an example to define hot key of different style switching, + note that I had only given this example without actually define it. + You can choose to define it in .vimrc or anyway you prefer. +> + nnoremap pc :let psc_style='cool':colo ps_color + nnoremap pw :let psc_style='warm':colo ps_color +< + Alternatively, you can use the capitalized :Colo command, like + :Colo cool or :Colo warm + +============================================================================== +PSC WITH CTERM *psc-cterm* + + Colour Term ~ + + The cterm color is designed mainly in these terminals: +> + 1. Cygwin bash shell in NT command prompt box + 2. XTERM and RXVT + 3. Other color terminals which have at least 16 colors +< + *psc-cterm-nt* + In Windows NT Prompt console you can change the exact value of each + color, so you can have the same color with your GUI version of Vim, + for 'cool' color style you just change the color according to the + |psc-cterm-color-table|, for how to redefine the color of Windows NT + prompt console please see Windows Help. + + NT Cygwin bash shell console supports 16 foreground colors by add bold + attribute to 8 color, the cterm=bold specifies which should be bright + color, so totally the 16 color foreground is available, but color + name DarkXXX and LightXXX are the same. + + The pre-configured Cygwin.lnk is available for download on my web page + for Vim, but the site seems down, and the my site would not be on + recently, you may need to change colors in the Properties menu... + + Cygwin is highly recommended for Vim user if you are using Windows NT + based systems (e.g. NT 4.0, Win2k, WinXP, Win2003, etc). But Cygwin is + not that versatile under Windows 95/98/ME. I'm not sure whether this + works for DOS DJGPP or Windows 95 console version of Vim because + I don't have the system, in case you encountered problem please + contact me, if you like. + + *psc-cterm-xterm* + XTERM is a much more feature-rich terminal than Windows Console so the + support is much better, add the following recommend line into your + .Xdefaults and you can achieve the same color as in GUI version. + + Add the following into your .Xdefaults: + This works for XTERM and RXVT. +> + XTerm*color0: #000000 + XTerm*color1: #800000 + XTerm*color2: #008000 + XTerm*color3: #d0d090 + XTerm*color4: #000080 + XTerm*color5: #800080 + XTerm*color6: #a6caf0 + XTerm*color7: #d0d0d0 + XTerm*color8: #b0b0b0 + XTerm*color9: #f08060 + XTerm*color10: #60f080 + XTerm*color11: #e0c060 + XTerm*color12: #80c0e0 + XTerm*color13: #f0c0f0 + XTerm*color14: #c0d8f8 + XTerm*color15: #e0e0e0 + XTerm*cursorColor: #00f000 + + ! The following are recommended but optional + XTerm*reverseVideo: False + XTerm*background: #000000 + XTerm*foreground: #d0d0d0 + XTerm*boldMode: False +< + There is an assumption that your RXVT or XTERM supports 16 colors, + most RXVTs and XTERMs support this, if yours do not, get a source of + RXVT and recompile it. + + Sometimes the color mode are not recognized well, or you do not want + bright foreground be bolded. If this is the case, add the following in + your .vimrc (before the color scheme been sourced) +> + if &term=='xterm' " Change 'xterm' to your term name if necessary + set t_Co=16 + endif +< + If the t_Co=16 have problem, set t_Co=8 and :colo ps_color again. + vice versa. + + My rxvt works well with t_Co=16: > + Rxvt v2.7.10 - released: 26 MARCH 2003 + Options: + XPM,transparent,utmp,menubar,frills,linespace,multichar_languages, + scrollbars=rxvt+NeXT+xterm,.Xdefaults +< But I've know that my rxvt v2.6.4 in another machine has problem with + t_Co=16, if that is the case, set t_Co=8 instead. + + *psc-cterm-others* + For other terminals, you can manually set the color according to the + following table + + Hints for Manually set the color (for 'cool' style only): + *psc-cterm-color-table* + Color name Hex value Decimal value ~ + 0 Black = #000000 0,0,0 + 4 DarkBlue = #000080 0,0,128 + 2 DarkGreen = #008000 0,128,0 + 6 DarkCyan = #a6caf0 166,202,240 + 1 DarkRed = #800000 128,0,0 + 5 DarkMagenta = #800080 128,0,128 + 3 DarkYellow = #d0d090 208,208,144 + 7 Grey = #d0d0d0 208,208,208 + 8 DarkGrey = #b0b0b0 176,176,176 + 12 Blue = #80c0e0 128,192,224 + 10 Green = #60f080 96,240,128 + 14 Cyan = #c0d8f8 192,216,248 + 9 Red = #f08060 240,128,96 + 13 LMag. = #f0c0f0 240,192,240 + 11 Yellow = #e0c060 224,192,96 + 15 White = #e0e0e0 224,224,224 + + *psc-cterm-incompatible* + If your color terminal does only have 8 colors and cannot achieve 16 + colors with cterm=bold, you may want to switch to other color schemes + to gain more readability. Anyway, you can specify in your .vimrc to + use different color scheme under different consoles and GUI. + For example: +> + let psc_cterm_style = 'foobarcolor' + let psc_style = 'cool' + colo ps_color +< + The 'foobarcolor' means the color scheme you want to choose, such as + 'desert', I recommend to try vim default schemes 'default' and + 'defdark' before experience others. + +============================================================================== +PSC FAQ AND TIPS *psc-faq* *psc-tips* +> + Q: What is meant by `PS' ? +< + A: PS means: PostScript, PhotoShop, PerSonal, ... or anything you can + imagine and anything you want it do be. +> + Q: How to obtain the same appreance as gui in color term? +< + A: This need some work around, see |psc-cterm| for details. + Generally speaking, you should ensure your color term has support + for 16 foreground colors, and each color is customizable. + + *psc-faq-ffothers* > + Q: How to use psc_fontface with other colorschemes? +< + A: Make sure you had sourced :colo ps_color in your .vimrc, then you + can use the Capitalized :Colo instead of :colo + e.g. you want to use 'murphy', just type :Colo murphy after you + sourced the ps_color, the 'defdark', 'cool', 'warm' can also be + used here. +> + Q: I updated from v2.0 to v2.3 or above, why the cterm color scheme + for Comment is different? +< + A: The color map of DarkYellow and Yellow have been exchanged, + You need to reconfigure your terminal to meet the change, + see |psc-cterm-color-table| for guide, or if you are using xterm + compatible terminal, just update the .XDefaults according to + |psc-cterm-xterm|. +> + Q: What do you mean by 'Vanilla Windows'? +< + A: People often argue that Windows is not a REAL operating system. + Well, I agree this, but only for vanilla windows. i.e. with no + plug-ins installed. Vanilla windows is a very limited platform, + since it is not POSIX compliant. + + There are currently many working around to make Windows POSIX + Compliant, do you still mind which OS to use when it is POSIX + Compliant? I don't. If you installed Cygwin kernel in your + NT-based Windows, the Windows will be more or less POSIX compliant + and you can use it in the same way as you use any Unix, BSD, + Solaris, Linux, XWindow, etc... What is more, Cygwin is not the + only kernel which makes Windows POSIX Compliant, make a google + search and you will find many alternatives. +> + Q: How to change the Normal background color? Why don't you use + different background for NonText group? +< + A: This is for compatibility, since we have to use only 8 colors as + background in a color terminal. For GUI you can change this, see + |psc-change-background| for details. +> + Q: I updated from 2.81- to 2.82+, why the default background changed? +< + A: This is for Bram's guideline, that dark schemes with black + background has too much contrast. + + However, you can change it back. see |psc-change-background| for + details. + +============================================================================== +PSC RELEASE NOTES *psc-release-notes* + + 2.90 Release Note: ~ + + Upon the release of Vim 7, many new highlight groups have been added. + + A style has been tuned a little to increase contrast. + + + 2.83 Release Note: ~ + + This is an identical version, but my e-mail address changed. + + + 2.82 Release Note: ~ + + Fixed bug with the reversed group for the Vim default, or other + schemes. + + Fixed bug with the Diff mode fg mistaken as fg. + + Shrink the script a lot to improve load performance, moved the release + notes into document. + + Change the default gui background color to #202020 (Dark Grey) + + + 2.81 Release Note: ~ + + Provided a separate utility reloaded.vim to fine tune the GUI color + scheme based on Hue, Saturation and Brightness(Luminance). + + Added some groups to meet the need of reloaded.vim, no essential + change. + + 2.8 Release Note: ~ + + Bugfix : when psc_style=='mixed', the visual got reversed wrong. + + 'mixed' is now the default for 'warm' style. + + changed the function name to lower case. + + removed pre-2.0 compatibility, (the non-psc version of s-d-f-t). + + Added variable psc_cterm_style, see |psc_cterm_style| + + Added group Underline + + Tuned the function call. + + 2.7 Release Note: ~ + + Now it is possible to change the Background, + see :h psc-change-background for details. + + Linked the Tag group to Identifier. + + NonText as Notice is not good for 'warm', changed to Constant. + + Added links for the most popular plugins: taglist, calendar + + Tuned the 'Statement' color when different from Type (gui only). + + Re-adjusted cterm scheme according to syntax/hitest.vim + + The 'defdark' style for cterm is not functioning, fixed. + + Many 'cosmetic' changes, makes no difference for functionality. + + Use of DrChip's help extractor to auto-install help document. + + Added command define, :Colo + + 2.6 Release Note: ~ + + As stated in the v2.3, the only 'todo' thing seems to be the 'warm' + style, now in this version I had been working on it. + + There also are some minor fixes for the document, to be more friendly + for new readers. + + The 'StatusLine' of 'cold' style is modified by mistake in the v2.3, + this time the bug is fixed. + + The 'Directory' in GUI 'cold' style is different from 'cterm' one, + now fixed. + + 2.3 Release Note: ~ + + This is an incompatible update, main changes are in 'cterm'. + A new group 'SignColumn' had been added, new links added for engspchk + v52, hundreds of typos fixed in the document, thanks to the engspchk. + + The support for 8-color cterm is slightly better now, but the mappings + of the DarkYellow and Yellow are exchanged, you need to update the + .Xdefaults or your terminal configuration before apply this update if + you are using v2.0. Guide for redefinition the color value is + available in the document, make sure you had updated the ps_color.txt, + then see |psc-cterm-color-table| + + 2.0 Release Note: ~ + + There've been great enhancement since this version, so I'd choose to + bump the version number to 2. This version comes with Vim online help, + if you had installed ps_color.txt, you can see for details in + |pscolor| + + n/a Release: ~ + + Initial upload, can be called as v1.8 + + +============================================================================== +PSC TODO LIST *psc-todo* + + . Fix the remain bugs. + . Follow the new Vim versions for new added highlighting group + . This cannot work in Vim Tiny mode, and will never work! + +============================================================================== + +vim:tw=78:ts=8:noet:ft=help:fo+=t:norl:noet: diff --git a/.vim/doc/tags b/.vim/doc/tags new file mode 100644 index 0000000..ad6507a --- /dev/null +++ b/.vim/doc/tags @@ -0,0 +1,28 @@ +ps_color.txt ps_color.txt /*ps_color.txt* +ps_colour ps_color.txt /*ps_colour* +psc ps_color.txt /*psc* +psc-about-background ps_color.txt /*psc-about-background* +psc-change-background ps_color.txt /*psc-change-background* +psc-contents ps_color.txt /*psc-contents* +psc-cterm ps_color.txt /*psc-cterm* +psc-cterm-color-table ps_color.txt /*psc-cterm-color-table* +psc-cterm-incompatible ps_color.txt /*psc-cterm-incompatible* +psc-cterm-nt ps_color.txt /*psc-cterm-nt* +psc-cterm-others ps_color.txt /*psc-cterm-others* +psc-cterm-xterm ps_color.txt /*psc-cterm-xterm* +psc-faq ps_color.txt /*psc-faq* +psc-faq-ffothers ps_color.txt /*psc-faq-ffothers* +psc-features ps_color.txt /*psc-features* +psc-options ps_color.txt /*psc-options* +psc-overview ps_color.txt /*psc-overview* +psc-release-notes ps_color.txt /*psc-release-notes* +psc-tips ps_color.txt /*psc-tips* +psc-todo ps_color.txt /*psc-todo* +psc-usage ps_color.txt /*psc-usage* +psc_cterm_style ps_color.txt /*psc_cterm_style* +psc_fontface ps_color.txt /*psc_fontface* +psc_inversed_todo ps_color.txt /*psc_inversed_todo* +psc_statement_different_from_type ps_color.txt /*psc_statement_different_from_type* +psc_style ps_color.txt /*psc_style* +psc_use_default_for_cterm ps_color.txt /*psc_use_default_for_cterm* +pscolor ps_color.txt /*pscolor* diff --git a/.vim/supertab.vim b/.vim/supertab.vim new file mode 100644 index 0000000..07351a7 --- /dev/null +++ b/.vim/supertab.vim @@ -0,0 +1,211 @@ +" Author: Gergely Kontra +" You may direct issues regarding version 0.4+ to +" Eric Van Dewoestine (ervandew@yahoo.com). +" Version: 0.41 +" Description: +" Use your tab key to do all your completion in insert mode! +" The script remembers the last completion type, and applies that. +" Eg.: You want to enter /usr/local/lib/povray3/ +" You type (in insert mode): +" /u/l/p/i +" You can also manipulate the completion type used by changing g:complType +" variable. +" You can cycle forward and backward with the and keys +" ( will not work in the console version) +" Note: you must press once to be able to cycle back +" History: +" 0.41 Fixed couple bugs introduced in last version (Eric Van Dewoestine). +" 0.4 Added the following functionality (Eric Van Dewoestine) +" - support for vim 7 omni, user, and spelling completion modes +" (should be backwards compatible with vim 6.x). +" - command :SuperTabHelp which opens a window with available +" completion types that the user can choose from. +" - variable g:SuperTabRetainCompletionType setting for determining if +" and for how long to retain completion type. +" 0.32 Corrected tab-insertion/completing decidion (thx to: Lorenz Wegener) +" 0.31 Added for backward cycling. (req by: Peter Chun) +" 0.3 Back to the roots. Autocompletion is another story... +" Now the prompt appears, when showmode is on + +if !exists('complType') "Integration with other completion functions... + + " This variable determines if, and for how long, the current completion type + " is retained. The possible values include: + " 0 - The current completion type is only retained for the current completion. + " Once you have chosen a completion result or exited the completion + " mode, the default completion type is restored. + " 1 - The current completion type is saved for the duration of your vim + " session or until you enter a different completion mode. + " (SuperTab default). + " 2 - The current completion type is saved until you exit insert mode (via + " ESC). Once you exit insert mode the default completion type is + " restored. + if !exists("g:SuperTabRetainCompletionType") + let g:SuperTabRetainCompletionType = 1 + endif + + " This variable is used to set the default completion type. + " There is no need to escape this value as that will be done for you when + " the type is set. + " Ex. let g:SuperTabDefaultCompletionType = "" + if !exists("g:SuperTabDefaultCompletionType") + let g:SuperTabDefaultCompletionType = "" + endif + + " construct the help text. + let s:tabHelp = + \ "Hit or CTRL-] on the completion type you wish to swith to.\n" . + \ "Use :help ins-completion for more information.\n" . + \ "\n" . + \ "|| - Keywords in 'complete' searching down.\n" . + \ "|| - Keywords in 'complete' searching up (SuperTab default).\n" . + \ "|| - Whole lines.\n" . + \ "|| - Keywords in current file.\n" . + \ "|| - Keywords in 'dictionary'.\n" . + \ "|| - Keywords in 'thesaurus', thesaurus-style.\n" . + \ "|| - Keywords in the current and included files.\n" . + \ "|| - Tags.\n" . + \ "|| - File names.\n" . + \ "|| - Definitions or macros.\n" . + \ "|| - Vim command-line." + if v:version >= 700 + let s:tabHelp = s:tabHelp . "\n" . + \ "|| - User defined completion.\n" . + \ "|| - Occult completion.\n" . + \ "|s| - Spelling suggestions." + endif + + " set the available completion types and modes. + let s:types = + \ "\\\\\\\\\\\\\" + let s:modes = '/^E/^Y/^L/^N/^K/^T/^I/^]/^F/^D/^V/^P' + if v:version >= 700 + let s:types = s:types . "\\\\s" + let s:modes = s:modes . '/^U/^O/s' + endif + let s:types = s:types . "np" + let s:modes = s:modes . '/n/p' + + " Globally available function that user's can use to create mappings to + " quickly switch completion modes. Useful when a user wants to restore the + " default or switch to another mode without having to kick off a completion + " of that type or use SuperTabHelp. + " Example mapping to restore SuperTab default: + " nmap :call SetSuperTabCompletionType("") + fu! SuperTabSetCompletionType (type) + exec "let g:complType = \"" . escape(a:type, '<') . "\"" + endf + + call SuperTabSetCompletionType(g:SuperTabDefaultCompletionType) + + im =CtrlXPP() + + " Setup mechanism to restore orignial completion type upon leaving insert + " mode if g:SuperTabDefaultCompletionType == 2 + if g:SuperTabRetainCompletionType == 2 + " pre vim 7, must map + if v:version < 700 + im + \ :call SuperTabSetCompletionType(g:SuperTabDefaultCompletionType) + + " since vim 7, we can use InsertLeave autocmd. + else + augroup supertab + autocmd InsertLeave * + \ call SuperTabSetCompletionType(g:SuperTabDefaultCompletionType) + augroup END + endif + endif + + fu! CtrlXPP() + if &smd + echo '' | echo '-- ^X++ mode (' . s:modes . ')' + endif + let complType=nr2char(getchar()) + if stridx(s:types, complType) != -1 + if stridx("\\",complType)!=-1 " no memory, just scroll... + return "\".complType + elseif stridx('np',complType)!=-1 + let complType=nr2char(char2nr(complType)-96) " char2nr('n')-char2nr("\ + inore + + " This way after hitting , hitting it once more will go to next match + " (because in XIM mode and mappings are ignored) + " and wont start a brand new completion + " The side effect, that in the beginning of line and inserts a + " , but I hope it may not be a problem... + ino =SuperTab('n') + ino =SuperTab('p') + + fu! SuperTab(command) + if (strpart(getline('.'),col('.')-2,1)=~'^\s\?$') + return "\" + else + " exception: if in mode, then should move up the list, and + " down the list. + if a:command == 'p' && g:complType == "\" + return "\" + endif + return g:complType + endif + endf + + fu! SuperTabHelp() + if bufwinnr("SuperTabHelp") == -1 + botright split SuperTabHelp + + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=delete + + let saved = @" + let @" = s:tabHelp + silent put + call cursor(1,1) + silent 1,delete + call cursor(4,1) + let @" = saved + exec "resize " . line('$') + + syntax match Special "|.\{-}|" + + setlocal readonly + setlocal nomodifiable + + nmap :call SetCompletionType() + nmap :call SetCompletionType() + else + exec bufwinnr("SuperTabHelp") . "winc w" + endif + endf + + fu! s:SetCompletionType () + let chosen = substitute(getline('.'), '.*|\(.*\)|.*', '\1', '') + if chosen != getline('.') + call SuperTabSetCompletionType(chosen) + close + winc p + endif + endf + + if !exists(":SuperTabHelp") + command SuperTabHelp :call SuperTabHelp() + endif +en diff --git a/.vim/syntax/motd.vim b/.vim/syntax/motd.vim new file mode 100644 index 0000000..6a5afb9 --- /dev/null +++ b/.vim/syntax/motd.vim @@ -0,0 +1,23 @@ +" Vim syntax file +" Language: MotD Public +" Maintainer: David Bushong + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn match motdSig "\(\s\s\+\|\t\)--\?.\+$\|\s--\?\w\+\s*$" +syn match motdThread "^\s\+\\[_-]" +syn match motdDate "^\d\+/\d\+\s" +syn match motdLink "https\?://\S\+" + +hi link motdSig String +hi link motdThread Type +hi link motdDate Number +hi link motdLink Underlined + +let b:current_syntax = "motd" diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..4f1e28f --- /dev/null +++ b/.vimrc @@ -0,0 +1,41 @@ +syntax on +"colorscheme slate +"colorscheme dante +colorscheme barak +set ts=4 +set nocompatible +set smartcase + +"Sources +source ~/.vim/supertab.vim +source ~/.vim/charm.vim +"source ~/.vim/syntax/motd.vim + +au BufNewFile,BufRead motd.public,/tmp/motd.public.r.* setf motd +"Highlighting features +autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete +let python_highlight_all = 1 + +set t_Co=16 +set t_Sf=ESC[3%dm +set t_Sb=ESC[4%dm + +"Remappings +nnoremap gn :tabnew +nnoremap gc :tabclose +nnoremap j gj +nnoremap k gk +vnoremap j gj +vnoremap k gk +nnoremap gj +nnoremap gk +vnoremap gj +vnoremap gk +inoremap gj +inoremap gk + +if !exists(":W") + command W :w +endif + +inoremap ;a diff --git a/.zprofile b/.zprofile new file mode 100644 index 0000000..8d4cb15 --- /dev/null +++ b/.zprofile @@ -0,0 +1,26 @@ +# $FreeBSD: src/share/skel/dot.profile,v 1.19.2.2 2002/07/13 16:29:10 mp Exp $ +# +# .profile - Bourne Shell startup script for login shells +# +# see also sh(1), environ(7). +# + +# remove /usr/games and /usr/X11R6/bin if you want +PATH=$HOME/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin; export PATH + +# Setting TERM is normally done through /etc/ttys. Do only override +# if you're sure that you'll never log in via telnet or xterm or a +# serial line. +# Use cons25l1 for iso-* fonts +# TERM=cons25; export TERM + +BLOCKSIZE=K; export BLOCKSIZE +EDITOR=vim; export EDITOR +PAGER=less; export PAGER + +# set ENV to a file invoked each time sh is started for interactive use. +ENV=$HOME/.zshrc; export ENV + +#alias ls='ls -FG' +#alias la='ls -FGal' +#source ~/.bashrc diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..ca5cf08 --- /dev/null +++ b/.zshenv @@ -0,0 +1,11 @@ +export NOBEEP="YES" # Stop that infernal beeping +export CLICOLOR="YES" # Show colors +export LSCOLORS="ExGxFxdxCxDxDxhbadExEx" # Look like bash +bindkey '\e[1~' beginning-of-line # Home key +bindkey '\e[4~' end-of-line # End key +bindkey '\e[H' beginning-of-line # Home key (alternate) +bindkey '\e[F' end-of-line # End key (alternate) +bindkey '\e[3~' forward-delete-char # Delete key +bindkey '\e[6~' end-of-history # Page down key +bindkey '\e[2~' redisplay # Insert key +bindkey '\e[5~' insert-last-word # Page up key diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..fff82cb --- /dev/null +++ b/.zshrc @@ -0,0 +1,38 @@ +#complist +autoload -U compinit +compinit +setopt extended_glob +bindkey -v +ZLS_COLORS=$LS_COLORS + + + setopt prompt_subst + + + ### + # See if we can use colors. + + autoload colors zsh/terminfo + if [[ "$terminfo[colors]" -ge 8 ]]; then + colors + fi + for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do + eval PR_LIGHT_$color='%{$terminfo[bold]$fg[${(L)color}]%}' + eval PR_$color='%{$fg[${(L)color}]%}' + (( count = $count + 1 )) + done + PR_NO_COLOUR="%{$terminfo[sgr0]%}" + + ### + # Decide whether to set a screen title + if [[ "$TERM" == "screen" ]]; then + PR_STITLE=$'%{\ekzsh\e\\%}' + else + PR_STITLE='' + fi + + PROMPT='$PR_STITLE$PR_LIGHT_BLUE($PR_LIGHT_YELLOW%D{%H:%M}|%!$PR_BLUE%)[%(!.$PR_RED.$PR_GREEN)%n@%m$PR_LIGHT_CYAN %~$PR_BLUE]$PR_NO_COLOUR%(!.#.$) ' + #source .zshprompt + +source ~/.bash_aliases +source ~/.zshenv diff --git a/bin/ansiabuse b/bin/ansiabuse new file mode 100755 index 0000000..a0670e6 --- /dev/null +++ b/bin/ansiabuse @@ -0,0 +1,16 @@ +#!/usr/bin/python +import random +import sys +import commands +colors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"] +for line in sys.stdin: + echostring = "" + line = line.rstrip(); + for x in line: + if x == '\\': + x = '\\\\' + colorname = colors[random.randint(0,6)] + echostring += "$(color lt" + colorname +")" + x + echostring += "$(color off)" + o = commands.getoutput('echo "' + echostring + '"') + print o.rstrip() diff --git a/bin/baraksetup b/bin/baraksetup new file mode 100755 index 0000000..6eb82be --- /dev/null +++ b/bin/baraksetup @@ -0,0 +1,4 @@ +#!/bin/bash +cd ~ +tar -czf baraksetup.tar.gz bin/ .vim/ .vimrc .bashrc .bash_aliases .bash_logout .profile .muttrc .screenrc .procmailrc +chmod 600 baraksetup.tar.gz diff --git a/bin/build/Makefile b/bin/build/Makefile new file mode 100644 index 0000000..f5f0e8e --- /dev/null +++ b/bin/build/Makefile @@ -0,0 +1,7 @@ +all: + gcc -o ./gettermsize ./src/gettermsize/gettermsize.c + gcc -o ./wye ./src/wye/wye.c + +install: + cp ./wye ~/bin + cp ./gettermsize ~/bin diff --git a/bin/build/src/gettermsize/gettermsize.c b/bin/build/src/gettermsize/gettermsize.c new file mode 100644 index 0000000..4361ac5 --- /dev/null +++ b/bin/build/src/gettermsize/gettermsize.c @@ -0,0 +1,15 @@ +#include +#include +#include + + +int main() +{ + struct winsize size; + ioctl(STDIN_FILENO, TIOCGWINSZ, (char *) &size); + printf("%d x %d\n", size.ws_col, size.ws_row); + return 0; +} + + + diff --git a/bin/build/src/wye/wye.1 b/bin/build/src/wye/wye.1 new file mode 100644 index 0000000..71ddcd1 --- /dev/null +++ b/bin/build/src/wye/wye.1 @@ -0,0 +1,59 @@ +.\" $Id: wye.1,v 1.1 1999-05-03 10:04:59-07 mconst Exp mconst $ +.TH WYE 1 +.fi +.SH NAME +wye \- another pipe fitting +.SH SYNOPSIS +\fC`\fIsubcommand\fP | wye`\fR (note the backquotes!) +.SH DESCRIPTION +The \fCwye\fR utility is used to create systems of pipes and fifos +(named pipes) more complicated than standard shell syntax allows. +A single invocation of \fCwye\fR has the following effect: a temporary +fifo is created; the name of this fifo is printed on standard output; +and \fCwye\fR exits, leaving a child process in the background to copy +any data received on standard input to the fifo. The net effect of +this is that you can use the expression \fC`\fIsubcommand\fP | wye`\fR +anywhere on a command line that you would use a filename, and the output of +\fIsubcommand\fP will be piped appropriately to create the illusion that +\fC`\fIsubcommand\fP | wye`\fR is a file, containing the output of +\fIsubcommand\fR. +.SH EXAMPLES +Since \fCwye\fR is a simple command, I have given it a simple +description; however, some examples are certainly in order. +To print all lines of the standard input which contain the name +of a file in the current directory: +.nf + + \fCfgrep \-f `ls | wye`\fR + +.fi +To show which users log on or off in the next minute: +.nf + + \fCdiff \-h `who | wye` `sleep 60; who | wye`\fR + +.fi +To change the names of all the files in the current directory to lowercase: +.nf + + \fCpaste `ls | wye` `ls | tr A\-Z a\-z | wye` | xargs \-n2 mv\fR +.fi +.SH FILES +\fC/tmp/wye.??????\fR temporary fifos +.SH BUGS +The background \fCwye\fR process has a (hardcoded) one-hour timeout: if the +fifo is not opened for reading by another process in that time, then the +background \fCwye\fR process will terminate silently. Note that this will +probably never happen unless the user has made a mistake and forgotten to +use the fifo for anything. +.PP +There is no equivalent of \fCmkstemp\fR(\fC3\fR) for fifos, so we +must provide the same functionality ourselves with \fCmktemp\fR(\fC3\fR) +and \fCmkfifo\fR(\fC2\fR), repeating the calls if +.SM EEXIST +is returned. +.SH AUTHOR +Michael Constant (mconst@csua.berkeley.edu). +.SH "SEE ALSO" +\fCmktemp\fR(\fC3\fR), \fCmkstemp\fR(\fC3\fR), \fCmkfifo\fR(\fC2\fR), +\fCtee\fR(\fC1\fR) diff --git a/bin/build/src/wye/wye.c b/bin/build/src/wye/wye.c new file mode 100644 index 0000000..2ba7466 --- /dev/null +++ b/bin/build/src/wye/wye.c @@ -0,0 +1,72 @@ +/* wye.c, written by Michael Constant (mconst@csua.berkeley.edu) and placed + * in the public domain. $Id: wye.c,v 1.1 1999-05-03 10:04:59-07 mconst $ */ + +#include +#include +#include +#include +#include +#include +#include + +#define TEMPMASK "/tmp/wye.XXXXXX" /* the name of our tempfile */ +#define TIMEOUT 3600 /* time we wait for the fifo to open */ + +void cleanup(int sig); + +char tempfile[]=TEMPMASK; + +int main() +{ + int ch; + FILE *fp; + + /* create the fifo. if we get EEXIST, then someone else created a + * file with our intended name right before we did; we should pick + * a new name and try again. see the source to mkstemp(3). */ + while (mkfifo(mktemp(tempfile), 0600) == -1) { + if (errno != EEXIST) { + perror("wye: couldn't create fifo"); + exit(1); + } + strcpy(tempfile, TEMPMASK); + } + + /* remove our tempfile if we die */ + signal(SIGHUP, cleanup); + signal(SIGINT, cleanup); + signal(SIGTERM, cleanup); + signal(SIGALRM, cleanup); + + /* fork a child to do the work */ + switch (fork()) { + case -1: + perror("wye: couldn't fork"); + exit(1); + + case 0: + fclose(stdout); /* this is necessary for `cmd | wye` */ + alarm(TIMEOUT); /* this is if the fifo never opens */ + + /* this will block until someone else opens the fifo */ + if ((fp = fopen(tempfile, "w")) == NULL) { + perror("wye: couldn't open fifo"); + exit(1); /* not as if anyone cares */ + } + + alarm(0); /* cancel the alarm */ + unlink(tempfile); /* so it disappears when we're done */ + while ((ch = getchar()) != EOF) putc(ch, fp); + exit(0); + } + + /* output the name of the fifo */ + printf("%s\n", tempfile); + exit(0); +} + +void cleanup(int sig) +{ + unlink(tempfile); + exit(2); +} diff --git a/bin/callout b/bin/callout new file mode 100755 index 0000000..5664189 --- /dev/null +++ b/bin/callout @@ -0,0 +1,13 @@ +#!/usr/bin/ruby + +x = readline() +x = x.strip +(x.length() + 4).times {print "*"} +print "\n" +print "* " +print x +print " *\n" + +(x.length() + 4).times {print "*"} +print "\n" + diff --git a/bin/contract b/bin/contract new file mode 100755 index 0000000..dcbad82 --- /dev/null +++ b/bin/contract @@ -0,0 +1,34 @@ +#!/usr/bin/python + +import sys + +loadfile = sys.stdin + +if len(sys.argv) == 1: + print "No command to run" + sys.exit(1) + +if len(sys.argv) == 3: + if sys.argv[2] != "-": + loadfile = open(sys.argv[2]) + +def add(x, y): + return x + y + +def sub(x, y): + return x - y + +def mult(x, y): + return x * y + +def div(x,y): + return x / y; + +lis = [] +for line in loadfile: + if line.strip() <> "": + x = float(line) + lis.append(x) + +print reduce(eval(sys.argv[1]), lis) + diff --git a/bin/createindex b/bin/createindex new file mode 100755 index 0000000..cb661f1 --- /dev/null +++ b/bin/createindex @@ -0,0 +1,10 @@ +#!/bin/sh + +echo "

" +#echo `basename \`pwd\`` +pwd | xargs basename | xargs echo +echo "

" +for file in * +do + echo "${file}
" +done diff --git a/bin/createtextimage b/bin/createtextimage new file mode 100755 index 0000000..00450be --- /dev/null +++ b/bin/createtextimage @@ -0,0 +1,6 @@ +#!/bin/bash +#This is a hack for now, as Debian has an older version of ImageMagick. The better (>= IM 6.8.5) way is below +#perl -pe 's/\n/\\n/' | convert -background lightblue -fill blue label:@- $* +#convert -background lightblue -fill blue label:@- $* +#convert -background none -box lightblue -font Courier -fill blue -pointsize 14 text:- -trim +repage -bordercolor lightblue -border 3 -background lightblue -flatten png:- +convert -background none -box white -font Courier -fill black -strokewidth 2 -pointsize 16 text:- -trim +repage -bordercolor white -border 3 -background white -flatten png:- diff --git a/bin/gettermsize b/bin/gettermsize new file mode 100755 index 0000000..474eee3 Binary files /dev/null and b/bin/gettermsize differ diff --git a/bin/gnuplottoppm b/bin/gnuplottoppm new file mode 100755 index 0000000..4940e09 --- /dev/null +++ b/bin/gnuplottoppm @@ -0,0 +1,19 @@ +#!/usr/bin/perl + + +$x = 0.6; +$y = 0.6; +$color = 1; +$gnuplot = "/usr/bin/gnuplot"; + + open (GNUPLOT, "|$gnuplot"); + print GNUPLOT <",">") + thisline = thisline.replace("\n", "
") + thisline = thisline.replace(" "," ") + concat = concat + thisline # + "
" +print concat + "" diff --git a/bin/jytecheck b/bin/jytecheck new file mode 100755 index 0000000..f7134cb --- /dev/null +++ b/bin/jytecheck @@ -0,0 +1,46 @@ +#!/usr/bin/ruby +require 'net/http' +require 'getoptlong' + +class JyteEntry + def initialize(vfor, vagainst, title) + @vfor = vfor + @vagainst = vagainst + @title = title + end + def print + printf "[\033[32m#@vfor\033[0m " + printf "\033[31m#@vagainst\033[0m]\t" + printf "#@title\n" + end +end + +opts = GetoptLong.new( + ["--number", "-n", GetoptLong::REQUIRED_ARGUMENT] + ) + +donum = 10 + +opts.each do |opt, arg| + if opt == "-n" or opt == "--number" + donum = arg.to_i + end +end +donuma = (donum / 10.0).ceil + + +jytes = Array.new() + +1.upto(donuma) do |num| + response = Net::HTTP.start("jyte.com").post("/claims", "page=#{num}") + + titles = (response.body.scan(%r{a class=\"claim_title\"\n\s*href=\"http:(.*?)\">\n\s*(.*?)\n\s*}m)) + votesfor = (response.body.scan(%r{votes_left_text_\d*\" style=\"color:#fff;\">(.*?)}m)) + votesagainst = (response.body.scan(%r{votes_right_text_\d*\" style=\"color:#fff;\">(.*?)}m)) + 0.upto(9) do |i| + jytes.push(JyteEntry.new(votesfor[i][0],votesagainst[i][0],titles[i][1])) + end +end + + +0.upto(donum - 1) {|x| jytes[x].print} diff --git a/bin/lessaccesslog b/bin/lessaccesslog new file mode 100755 index 0000000..2b6f3f0 --- /dev/null +++ b/bin/lessaccesslog @@ -0,0 +1,2 @@ +#!/bin/bash +cat $1 | cut -d ] -f 2 | cut -d \" -f 2 | cut -d " " -f 2 | sort | uniq -c | sort -n | less diff --git a/bin/mailheaders b/bin/mailheaders new file mode 100755 index 0000000..6fc5562 --- /dev/null +++ b/bin/mailheaders @@ -0,0 +1,21 @@ +#!/usr/bin/perl +if ($#ARGV == 0) { + $ARGV[1] = "michener\@csua.berkeley.edu"; +} +print <) { + print; +} +print "."; +print "\n"; +print "QUIT"; +print "\n"; diff --git a/bin/motdedit b/bin/motdedit new file mode 100755 index 0000000..ceb7c2d --- /dev/null +++ b/bin/motdedit @@ -0,0 +1,184 @@ +#!/usr/local/bin/perl +# +# DESC: +# Program is used to sychronize write access to public motd file. +# Program acquires advisory exclusive lock, then brings up editor +# to edit file. On return from editor, motd file will be unlocked. +# If program cannot acquire exclusive lock, it prints out the current +# user holding exclusive lock. +# +# WRITTEN BY: +# Andrew Choi +# Fixed by: +# Ben Scott +# Arvin Hsu + +use strict; +use Fcntl ':flock'; +use Errno; +use Getopt::Std; +use File::Copy; + +my $motd = "/etc/motd.public"; +my $motdbackup = "/tmp/motd.public.b.$>.$$"; # EUID + PID +my $motdcurrent = "/tmp/motd.public.r.$>.$$"; # EUID + PID +my $motdtemp = "/tmp/motd.public.t.$>.$$"; # EUID + PID +my $motdmerged = "/tmp/motd.public.m.$>.$$"; # EUID + PID + +$motd = "/csua/tmp/motd.kinney" if (getpwuid($<))[0] eq 'kinney'; +my $editor = $ENV{MOTDEDITOR}; +$editor ||= $ENV{VISUAL}; +$editor ||= $ENV{EDITOR}; +$editor ||= "/usr/bin/ed"; + +my %opt; + +$opt{t} = 600; +getopts("mnst:h?",\%opt); +&Usage if $opt{h}; + +## Set environment vars for vi users +## Thanks, jon. + +$ENV{NEXINIT} ||= $ENV{EXINIT}; +unless ( $ENV{NEXINIT} ) { + unless (open (EXRC,"$ENV{HOME}/.nexrc")) { + unless (open (EXRC,"$ENV{HOME}/.exrc")) { + $ENV{NEXINIT} = "set nolock"; + } + } + unless ($ENV{NEXINIT}) { + ($ENV{NEXINIT} = join ("",)) && close EXRC; + } +} +$ENV{NEXINIT} .= "\nset nolock\n"; + +# Set alarm for being locked too damn long +$SIG{ALRM} = \&Unlock; +alarm $opt{t}; + +# Open file as append so that lock can be used on it +open(M, "$motd") || die "open $motd: $!"; + +# Lock file. If success, execute edit command and exit +flock(M, LOCK_EX|LOCK_NB); +if ($!{EWOULDBLOCK}) { + if ($opt{n}) { + print "Motd currently locked. Editing anyways."; + &Edit; + } + else { + flock (M, LOCK_UN); + print "Motd currently locked\nWait to acquire lock [y/N] "; + chomp(my $ans = <>); + if ($ans =~ /^y$/i) { + flock(M, LOCK_EX); + &Edit; + } + } +} else { + &Edit; +} + +close M; +system "/csua/bin/mtd"; +exit 0; + +sub Unlock { + flock(M, LOCK_UN); + print +"\r*** MOTD GOD PRONOUNCES: *** \r\n*** You have locked the motd for too long, you idle hoser... *** \r\n*** Your lock has been removed. *** \r\n"; +} + +sub Usage { + print STDERR +"$0 Edit /etc/motd.public with locking and merge. + +Usage: $0 [-m] [-s] [-t n] + -t n Set timeout for releasing lock to n seconds (default $opt{t}) + -m Turns auto-merging off. + -s If merge fails, will stomp over other changes. + -n Does not wait for lock before allowing edit. + (the other person may overwrite your post) +"; + exit 2; +} + +sub Edit { + alarm $opt{t}; + print ""; + #check if merge option is desired + if (!$opt{m}) { + copy($motd,$motdbackup); + copy($motd,$motdcurrent); + my $lastmodtime = (stat($motd))[9]; + system("$editor $motdcurrent"); + my $currmodtime = (stat($motd))[9]; + if ($currmodtime > $lastmodtime) { + &Merge; + } + else { + copy($motdcurrent,$motd); + } + unlink ; + } + else { + system("$editor $motd"); + } +} + + +# Attempts to auto-merge using "merge, diff -c | patch, diff | patch" +# If auto-merge fails, allows manual merge +# Saves final version as $motd +sub Merge { + copy($motd,$motdmerged); + system("merge -p -q -L \"Other Changes Below\" -L \"Original MOTD\" -L \"Your Changes Above\" $motd $motdbackup $motdcurrent > $motdtemp"); + + # Check to see if merge failed. if fail, try diff -c | patch + if (($? >> 8) > 0) { + system("diff -c $motdbackup $motdcurrent | patch -s -f $motdmerged 2> /dev/null"); + + # Check to see if diff -c | patch, if fail, try diff | patch + if (($? >> 8) > 0) { + system("diff $motdbackup $motdcurrent | patch -s -f $motdmerged 2> /dev/null"); + + # If everything has failed, put the merge notation in, and let the user edit. + if (($? >> 8) > 0) { + if ($opt{s}) { + copy($motdcurrent,$motdmerged); + } + else { + print "CONCURRENT CHANGES\r\nAll merge & patch attempts have failed.\r\nMerge Manually? [y/n]"; + chomp(my $answ = <>); + if ($answ =~ /^y$/i) { + copy($motdtemp,$motdcurrent); + copy($motd,$motdbackup); + my $lastmodtime = (stat($motd))[9]; + system("$editor $motdcurrent"); + my $currmodtime = (stat($motd))[9]; + if ($currmodtime > $lastmodtime) { + &Merge; + } + else { + copy($motdcurrent,$motdmerged); + } + } + else { + print "Stomp on other people's changes? [y/n]"; + chomp(my $answ = <>); + if ($answ =~ /^y$/i) { + copy($motdcurrent,$motdmerged); + } + } + } + } + } + } + else { + # Merge was successful, copy it over. + copy($motdtemp,$motdmerged); + } + copy($motdmerged,$motd); +} + diff --git a/bin/movingaverage b/bin/movingaverage new file mode 100755 index 0000000..b0665e1 --- /dev/null +++ b/bin/movingaverage @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +$averageto = $ARGV[0]; +for ($i = 0; $i < $averageto; $i++) { + $temp[$i] = 0; +} + +while () { + chomp; + $x = 0; + for ($i = 0; $i < $averageto; $i++) { + $x += $temp[$i]; + } + $x = $x + $_; + $x = $x / ($averageto + 1); + print "$x\n"; + for ($i = 0; $i < $averageto - 1; $i++) { + $temp[$i] = $temp[($i + 1)]; + } + $temp[($averageto -1)] = $_; +} diff --git a/bin/noblanks b/bin/noblanks new file mode 100755 index 0000000..8ff63f1 --- /dev/null +++ b/bin/noblanks @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +while () { + chomp($_); + if ($_){ + print "$_\n"; + } +} diff --git a/bin/orly b/bin/orly new file mode 100755 index 0000000..68f664e --- /dev/null +++ b/bin/orly @@ -0,0 +1,119 @@ +#!/usr/bin/perl + +# +# Globals +# +use vars qw/$deftext %opt /; + +# +# Command line options processing +# +sub init() +{ + use Getopt::Std; + my $opt_string = 'hdoynsi'; + getopts( "$opt_string", \%opt ) or usage(); + usage() if $opt{h}; +} + +# +# Message about this program and how to use it +# +sub usage() +{ + print STDERR << "EOF"; + +orly -- Print an O RLY owl + +usage: $0 [-hdoyn] [] + + -h : this (help) message + -o, -d : print the "O RLY" owl + -y : print the "YA RLY" owl + -n : print the "NO WAI!" owl + -s : Print "SRSLY" as a question, statement or + exclamation, respectively for the above. + -i : take MESSAGE from STDIN + +EOF + exit; +} + +sub printorly() { + $deftext = "O RLY?"; + print << "EOO" + ___ +{o,o} +|)__) +-"-"- +EOO +} + +sub printyarly() { + $deftext = "YA RLY"; + print << "EOO" + ___ +{o.o} +|)_(| +-"-"- +EOO +} + +sub printnowai() { + $deftext = "NO WAI!"; + print << "EOO" + ___ + {o,o} + (__(| + -"-"- +EOO +} + +$givenstatement = ""; +for ($i=0; $i<($#ARGV + 1); $i++) +{ + if (substr($ARGV[$i],0,1) ne "-") + { + $up = uc($ARGV[$i]); + $givenstatement = "$givenstatement$up "; + } +} + +init(); + +if ($opt{i}) { + while () { + $givenstatement = $givenstatement.uc($_); + } + chomp($givenstatement); +} +if ($opt{y}) { + printyarly(); + $deftext = "SRSLY" if ($opt{s}); +} +elsif ($opt{n}) { + printnowai(); + $deftext = "SRSLY!" if ($opt{s}); +} +elsif ($opt{d} || $opt {o}) { + printorly(); + $deftext = "SRSLY?" if ($opt{s}); +} +elsif ($opt{s}) { + printyarly(); + $deftext = "SRSLY"; +} +else { + printorly(); +} + +if ($givenstatement) +{ + print "$givenstatement\n"; +} +else +{ + print "$deftext\n"; +} + +exit; diff --git a/bin/ownerof b/bin/ownerof new file mode 100755 index 0000000..83203eb --- /dev/null +++ b/bin/ownerof @@ -0,0 +1,3 @@ +#!/bin/sh +X=`ls -al $1 | awk '{print $3 ":" $4}'` +echo $X diff --git a/bin/planout b/bin/planout new file mode 100755 index 0000000..6f12a81 --- /dev/null +++ b/bin/planout @@ -0,0 +1,8 @@ +#!/bin/bash +cat ~/.plan_real +echo "" +echo "Politburo Meeting .plan:" +sed -n '/^*/p' ~/.csua.plan +wc ~/.csua.plan +echo "" +~/bin/randsonnet diff --git a/bin/port25cow b/bin/port25cow new file mode 100755 index 0000000..352b51f --- /dev/null +++ b/bin/port25cow @@ -0,0 +1,2 @@ +#!/bin/bash +cowsay $1 | mailheaders $1 $2 diff --git a/bin/ps_warriors b/bin/ps_warriors new file mode 100755 index 0000000..9aad4f0 --- /dev/null +++ b/bin/ps_warriors @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +$cnt = ($ARGV[0] eq "-n" && $ARGV[1] =~ /^\d+$/) ? $ARGV[1] : 20; + +opendir(PROC, "/proc"); +while ($_ = readdir(PROC)) { + next if (/curproc/); + $id = (stat("/proc/$_"))[4]; + next unless defined $id; + $procs{$id}++; +} +closedir(PROC); + +$procs{$<}--; +@ids = reverse sort { $procs{$a} <=> $procs{$b} } keys(%procs); + +format STDOUT = +@>>> @<<<<<<< +$procs{$id}, (getpwuid($id))[0] +. + +for $id (($cnt) ? @ids[0..($cnt-1)] : @ids) { + write; +} diff --git a/bin/randsonnet b/bin/randsonnet new file mode 100755 index 0000000..7bde889 --- /dev/null +++ b/bin/randsonnet @@ -0,0 +1,7 @@ +#!/usr/bin/python +import random +import commands +x = random.randint(1,154) +o = commands.getoutput("~/bin/grepsonnet %d" % x) +print "Random Shakespeare Sonnet:" +print o diff --git a/bin/rcpt b/bin/rcpt new file mode 100755 index 0000000..9ad7636 --- /dev/null +++ b/bin/rcpt @@ -0,0 +1,195 @@ +#! /usr/bin/perl -w +# +# This script connects to a mail server and issues MAIL and RCPT +# commands. It's a good way to check whether an address exists -- +# many modern mail servers actually respond usefully to RCPT, even +# if they ignore VRFY and EXPN. It's also convenient for testing +# whether a server allows relaying. +# +# usage: rcpt [options] email-address [mailserver] +# rcpt [options] -n [hostname] [mailserver] +# +# -n +# nonexistent: Make up an email address that probably doesn't +# exist at the specified hostname. For example, +# "rcpt -n foobar.com" will use an address like +# . If you don't +# specify a hostname, it'll make up a local address. +# (If you specify an email address instead of a hostname, +# it's treated as if you just gave the hostname part.) +# +# -v +# verbose: Show the entire SMTP exchange. +# +# -f ADDR +# from: Specify the address you're sending mail from. +# By default, the script uses its best guess at your +# email address, constructed from your username and +# the local host name. +# +# -h HOSTNAME +# helo: Specify the hostname to send in the HELO command. +# By default, the script uses its best guess at the +# fully-qualified domain name of the local host. +# +# By default, the script connects to the first MX listed for the +# email address you're testing. If that's not what you want, you +# can specify a mail server explicitly; you can even give a mail +# server of the form "mx:hostname", which means the first MX listed +# for "hostname". +# +# For example: +# +# rcpt user@foobar.com +# Connect to the first MX for foobar.com, and try the +# address . +# +# rcpt user@foobar.com mail.baz.com +# Connect to mail.baz.com, and try the address . +# +# rcpt user@foobar.com mx:baz.com +# Connect to the first MX for baz.com, and try the address +# . +# +# rcpt user +# Connect to localhost, and try the address . +# +# rcpt -n foobar.com +# Connect to the first MX for foobar.com, and try an +# address like . +# +# rcpt -n +# Connect to localhost, and try an address like +# . +# +# The script outputs the name of the server it connects to, followed +# by the response to the RCPT command. It returns success if the +# server accepts the address. +# +# $Id: rcpt,v 1.3 2006-10-12 01:37:51-07 mconst Exp mconst $ + + +use IO::Socket; +use Email::Address; +use Net::DNS; +use Net::SMTP; +use Sys::Hostname::Long; +use Getopt::Std; +use String::Random; + +$0 =~ s|.*/||; + + +# Return the first MX for the specified host. +sub get_mx { + my ($host) = @_; + + my @mx = mx($host) or die "$0: can't find MX for $host\n"; + return $mx[0]->exchange; +} + + +sub Net::SMTP::debug_print { + my ($self, $dir, @text) = @_; + return unless $self =~ /GLOB/; + + $arrows = $dir ? ">>> " : ""; + print $arrows, @text; +} + + +getopts "nvf:h:", \my %options; +my $verbose = $options{v}; +my $nonexistent = $options{n}; +my $helo_hostname = $options{h} || hostname_long; + +my $from_address = $options{f}; +if (!defined($from_address)) { + my $my_username = $ENV{USER} || getpwuid $< + || die "$0: can't find local username\n"; + + $from_address = "$my_username\@" . hostname_long; +} + + +my ($address, $server) = @ARGV; +@ARGV == 1 || @ARGV == 2 || (@ARGV == 0 && $nonexistent) + or die "usage: $0 email-address [mailserver]\n"; + +if ($nonexistent) { + my $nonexistent_user = String::Random::random_regex '[a-z]\w{10}' + . "-nonexistent"; + + if (!defined($address)) { + # The user didn't give us anything. Make up a local address. + + $address = $nonexistent_user; + } elsif ($address =~ /\@/) { + # The user gave us an entire email address -- we'll assume + # they want us to replace the user part with a made-up + # nonexistent username. + + $address = "$nonexistent_user\@$'"; + } else { + # The user gave us a hostname. Make up an address at that + # host. + + $address = "$nonexistent_user\@$address"; + } +} + + +if (!defined($server)) { + # The user didn't specify what mail server to connect to; try to + # figure it out from the address. + + my @addr_objects = Email::Address->parse($address); + + if (@addr_objects) { + # We found an address. Look up the MX for that host. + + die "$0: we only handle one address at a time for now\n" + if @addr_objects > 1; + my $addr_object = $addr_objects[0]; + + $server = get_mx($addr_object->host); + } else { + # We couldn't parse the address, so assume it's local. + # Local delivery is potentially a lot more complicated than + # this, but let's ignore that for now. + + $server = "localhost"; + } +} elsif ($server =~ /^mx:/i) { + # The user has explicitly requested that we look up the MX for + # a particular host, and use that as our server. + + $server = get_mx($'); +} + + +print "Connecting to $server...\n" if $verbose; +my $exit_code = 0; + +my $smtp = Net::SMTP->new($server, Hello => $helo_hostname, + ExactAddresses => 1, Debug => $verbose) + or die "$0: can't connect to $server\n"; + +if ($smtp->mail($from_address)) { + # The server accepted our MAIL command; go ahead and try the RCPT. + + $smtp->to($address) or $exit_code = 1; + $output = "$server: " . $smtp->code . " " . $smtp->message; +} else { + # The server rejected out MAIL command. We're done here. + + $exit_code = 2; + $output = "server rejected our From address of <$from_address>:\n" + . "$server: " . $smtp->code . " " . $smtp->message; +} + +$smtp->quit; + +print $output unless $verbose; + +exit $exit_code; diff --git a/bin/shakegrep b/bin/shakegrep new file mode 100755 index 0000000..0f4d15e --- /dev/null +++ b/bin/shakegrep @@ -0,0 +1,4 @@ +#!/bin/bash +#echo $2 +#agrep -n -i -d '$$' -t -r "$*" ~/shakespeare | sed '/\/.*\/[A-Za-z]*:/ s/:\s*/:\n/' +agrep -i -d '$$' -t -r "$1" /home/michener/shakespeare/**/*$2* | sed '/\/.*\/[A-Za-z0-9]*:/ s/:\s*/:\n/' diff --git a/bin/showansicol b/bin/showansicol new file mode 100755 index 0000000..ac9fc52 --- /dev/null +++ b/bin/showansicol @@ -0,0 +1,18 @@ +#!/bin/sh +############################################################ +# Nico Golde nico@ngolde.de Homepage: http://www.ngolde.de +# Letzte Änderung: Mon Feb 16 16:24:41 CET 2004 +############################################################ + +for attr in 0 1 4 5 7 ; do + echo "----------------------------------------------------------------" + printf "ESC[%s;Foreground;Background - \n" $attr + for fore in 30 31 32 33 34 35 36 37; do + for back in 40 41 42 43 44 45 46 47; do + printf '\033[%s;%s;%sm %02s;%02s ' $attr $fore $back $fore $back + done + printf '\n' + done + printf '\033[0m' +done + diff --git a/bin/splitquerystring b/bin/splitquerystring new file mode 100755 index 0000000..215dcb7 --- /dev/null +++ b/bin/splitquerystring @@ -0,0 +1,3 @@ +#!/bin/bash + +echo $QUERY_STRING | sed 's/%20/ /g' | sed 's/&/\n/g' diff --git a/bin/streamvideo b/bin/streamvideo new file mode 100755 index 0000000..3314d9d --- /dev/null +++ b/bin/streamvideo @@ -0,0 +1,2 @@ +#!/bin/bash +pv /home/michener/src/videostream/testscript.txt $1 | nc -l -p 49300 diff --git a/bin/tfc b/bin/tfc new file mode 100755 index 0000000..398b84f --- /dev/null +++ b/bin/tfc @@ -0,0 +1,346 @@ +#!/usr/bin/ruby + +TFCStrings = { 'he' => [ + [ + "a superhumanly strong", + "an underprivileged", + "a globe-trotting", + "an impetuous", + "a shy", + "a suave", + "a notorious", + "a one-legged", + "an all-American", + "a short-sighted", + "an otherworldly", + "a hate-fuelled", + "a scrappy", + "an unconventional", + "a jaded", + "a leather-clad", + "a fiendish", + "a Nobel prize-winning", + "a suicidal", + "a maverick", + "a bookish", + "an old-fashioned", + "a witless", + "a lounge-singing", + "a war-weary", + "a scarfaced", + "a gun-slinging", + "an obese", + "a time-tossed", + "a benighted", + "an uncontrollable", + "an immortal", + "an oversexed", + "a world-famous", + "an ungodly", + "a fast talking", + "a deeply religious", + "a lonely", + "a sword-wielding", + "a genetically engineered", + ],[ + "white trash", + "zombie", + "shark-wrestling", + "playboy", + "guitar-strumming", + "Jewish", + "sweet-toothed", + "bohemian", + "crooked", + "chivalrous", + "moralistic", + "amnesiac", + "devious", + "drug-addicted", + "voodoo", + "Catholic", + "overambitious", + "coffee-fuelled", + "pirate", + "misogynist", + "skateboarding", + "arachnophobic", + "Amish", + "small-town", + "Republican", + "one-eyed", + "gay", + "guerilla", + "vegetarian", + "dishevelled", + "alcoholic", + "flyboy", + "ninja", + "albino", + "hunchbacked", + "neurotic", + "umbrella-wielding", + "native American", + "soccer-playing", + "day-dreaming", + ],[ + "grifter", + "stage actor", + "paramedic", + "gentleman spy", + "jungle king", + "hairdresser", + "photographer", + "ex-con", + "vagrant", + "filmmaker", + "werewolf", + "senator", + "romance novelist", + "shaman", + "cop", + "rock star", + "farmboy", + "cat burglar", + "cowboy", + "cyborg", + "inventor", + "assassin", + "boxer", + "dog-catcher", + "master criminal", + "gangster", + "firefighter", + "househusband", + "dwarf", + "librarian", + "paranormal investigator", + "Green Beret", + "waffle chef", + "vampire hunter", + "messiah", + "astronaut", + "sorceror", + "card shark", + "matador", + "barbarian", + ],[ + "with a robot buddy named Sparky.", + "whom everyone believes is mad.", + "gone bad.", + "with a mysterious suitcase handcuffed to his arm.", + "living undercover at Ringling Bros. Circus.", + "searching for his wife's true killer.", + "who dotes on his loving old ma.", + "looking for 'the Big One.'", + "who knows the secret of the alien invasion.", + "on the edge.", + "on a mission from God.", + "with a secret.", + "in drag.", + "", + "plagued by the memory of his family's brutal murder.", + "looking for a cure to the poison coursing through his veins.", + "moving from town to town, + helping folk in trouble.", + "who must take medication to keep him sane.", + "who hangs with the wrong crowd.", + "possessed of the uncanny powers of an insect.", + "with a winning smile and a way with the ladies.", + "fleeing from a secret government programme.", + "from the 'hood.", + "haunted by an iconic dead American confidante.", + "with a passion for fast cars.", + "trapped in a world he never made.", + "in a wheelchair.", + "on the hunt for the last specimen of a great and near-mythical creature.", + "on the run.", + "for the 21st century.", + "who hides his scarred face behind a mask.", + "on the wrong side of the law.", + "with no name.", + "from the Mississippi delta.", + "with acid for blood.", + "with nothing left to lose.", + "haunted by memories of 'Nam.", + "on a search for his missing sister.", + "on his last day in the job.", + "from a doomed world.", + "who believes he can never love again.", + ] +], 'she' => [ + [ + "a radical", + "a green-fingered", + "a tortured", + "a time-travelling", + "a vivacious", + "a scantily clad", + "a mistrustful", + "a violent", + "a transdimensional", + "a strong-willed", + "a ditzy", + "a man-hating", + "a high-kicking", + "a blind", + "an elegant", + "a supernatural", + "a foxy", + "a bloodthirsty", + "a cynical", + "a beautiful", + "a plucky", + "a sarcastic", + "a psychotic", + "a hard-bitten", + "a manipulative", + "an orphaned", + "a cosmopolitan", + "a chain-smoking", + "a cold-hearted", + "a warm-hearted", + "a sharp-shooting", + "an enchanted", + "a wealthy", + "a pregnant", + "a mentally unstable", + "a virginal", + "a brilliant", + "a disco-crazy", + "a provocative", + "an artistic" + ],[ + "tempestuous", + "Buddhist", + "foul-mouthed", + "nymphomaniac", + "green-skinned", + "impetuous", + "African-American", + "punk", + "hypochondriac", + "junkie", + "blonde", + "goth", + "insomniac", + "gypsy", + "mutant", + "renegade", + "tomboy", + "French-Canadian", + "motormouth", + "belly-dancing", + "communist", + "hip-hop", + "thirtysomething", + "cigar-chomping", + "extravagent", + "out-of-work", + "Bolivian", + "mute", + "cat-loving", + "snooty", + "wisecracking", + "red-headed", + "winged", + "kleptomaniac", + "antique-collecting", + "psychic", + "gold-digging", + "bisexual", + "paranoid", + "streetsmart" + ],[ + "archaeologist", + "pearl diver", + "mechanic", + "detective", + "hooker", + "femme fatale", + "former first lady", + "barmaid", + "fairy princess", + "magician's assistant", + "schoolgirl", + "college professor", + "angel", + "bounty hunter", + "opera singer", + "cab driver", + "soap star", + "doctor", + "politician", + "lawyer", + "nun", + "snake charmer", + "journalist", + "bodyguard", + "vampire", + "stripper", + "Valkyrie", + "wrestler", + "mermaid", + "single mother", + "safe cracker", + "traffic cop", + "research scientist", + "queen of the dead", + "Hell's Angel", + "museum curator", + "advertising executive", + "widow", + "mercenary", + "socialite" + ],[ + "on her way to prison for a murder she didn't commit.", + "trying to make a difference in a man's world.", + "with the soul of a mighty warrior.", + "looking for love in all the wrong places.", + "with an MBA from Harvard.", + "who hides her beauty behind a pair of thick-framed spectacles.", + "with the power to see death.", + "descended from a line of powerful witches.", + "from a family of eight older brothers.", + "with a flame-thrower.", + "with her own daytime radio talk show.", + "living on borrowed time.", + "who can talk to animals.", + "prone to fits of savage, + blood-crazed rage.", + "who don't take no shit from nobody.", + "with a knack for trouble.", + "who believes she is the reincarnation of an ancient Egyptian queen.", + "fleeing from a Satanic cult.", + "on the trail of a serial killer.", + "with a birthmark shaped like Liberty's torch.", + "in the witness protection scheme.", + "from out of town.", + "from aristocratic European stock.", + "living homeless in New York's sewers.", + "with only herself to blame.", + "from beyond the grave.", + "married to the Mob.", + "from the wrong side of the tracks.", + "from a secret island of warrior women.", + "from Mars.", + "with someone else's memories.", + "from a different time and place.", + "operating on the wrong side of the law.", + "who inherited a spooky stately manor from her late maiden aunt.", + "who dreams of becoming Elvis.", + "with a song in her heart and a spring in her step.", + "in the wrong place at the wrong time.", + "with an incredible destiny.", + "with the power to bend men's minds.", + "with an evil twin sister." + ] +] } + +def descr(gender) + (0..3).to_a.map { |n| + TFCStrings[gender][n][rand(TFCStrings[gender][n].size)] + }.join(' ').sub(/ $/, '.') +end + +puts("He's " + descr('he') + " She's " + descr('she') + ' They fight crime!') diff --git a/bin/theyfightcrime b/bin/theyfightcrime new file mode 100755 index 0000000..bd7940a --- /dev/null +++ b/bin/theyfightcrime @@ -0,0 +1,35 @@ +#!/usr/bin/python +# +# They Fight Crime! +# +# taken from the Javascript at +# http://home.epix.net/~mhryvnak/theyfightcrime.html +# and translated into python by B. Michener +# + +import random + +#init a; +a = [0, 1, 2, 3, 4, 5, 6, 7] +for i in range(0,8): + a[i] = random.randint(0,39) + +he1 = ["a superhumanly strong","an underprivileged","a globe-trotting","an impetuous","a shy","a suave","a notorious","a one-legged","an all-American","a short-sighted","an otherworldly","a hate-fuelled","a scrappy","an unconventional","a jaded","a leather-clad","a fiendish","a Nobel prize-winning","a suicidal","a maverick","a bookish","an old-fashioned","a witless","a lounge-singing","a war-weary","a scarfaced","a gun-slinging","an obese","a time-tossed","a benighted","an uncontrollable","an immortal","an oversexed","a world-famous","an ungodly","a fast talking","a deeply religious","a lonely","a sword-wielding","a genetically engineered"] + +he2 = ["white trash","zombie","shark-wrestling","playboy","guitar-strumming","Jewish","sweet-toothed","bohemian","crooked","chivalrous","moralistic","amnesiac","devious","drug-addicted","voodoo","Catholic","overambitious","coffee-fuelled","pirate","misogynist","skateboarding","arachnophobic","Amish","small-town","Republican","one-eyed","gay","guerilla","vegetarian","dishevelled","alcoholic","flyboy","ninja","albino","hunchbacked","neurotic","umbrella-wielding","native American","soccer-playing","day-dreaming"] + +he3 = ["grifter","stage actor","paramedic","gentleman spy","jungle king","hairdresser","photographer","ex-con","vagrant","filmmaker","werewolf","senator","romance novelist","shaman","cop","rock star","farmboy","cat burglar","cowboy","cyborg","inventor","assassin","boxer","dog-catcher","master criminal","gangster","firefighter","househusband","dwarf","librarian","paranormal investigator","Green Beret","waffle chef","vampire hunter","messiah","astronaut","sorceror","card sharp","matador","barbarian"] + +he4 = ["with a robot buddy named Sparky.","whom everyone believes is mad.","gone bad.","with a mysterious suitcase handcuffed to his arm.","living undercover at Ringling Bros. Circus.","searching for his wife's true killer.","who dotes on his loving old ma.","looking for 'the Big One.'","who knows the secret of the alien invasion.","on the edge.","on a mission from God.","with a secret.","in drag.","","plagued by the memory of his family's brutal murder.","looking for a cure to the poison coursing through his veins.","moving from town to town, helping folk in trouble.","who must take medication to keep him sane.","who hangs with the wrong crowd.","possessed of the uncanny powers of an insect.","with a winning smile and a way with the ladies.","fleeing from a secret government programme.","from the 'hood.","haunted by an iconic dead American confidante","with a passion for fast cars.","trapped in a world he never made.","in a wheelchair.","on the hunt for the last specimen of a great and near-mythical creature.","on the run.","for the 21st century.","who hides his scarred face behind a mask.","on the wrong side of the law.","with no name.","from the Mississippi delta.","with acid for blood.","with nothing left to lose.","haunted by memories of 'Nam.","on a search for his missing sister.","on his last day in the job.","from a doomed world.","who believes he can never love again."] + +she1 = ["a radical","a green-fingered","a tortured","a time-travelling","a vivacious","a scantily clad","a mistrustful","a violent","a transdimensional","a strong-willed","a ditzy","a man-hating","a high-kicking","a blind","an elegant","a supernatural","a foxy","a bloodthirsty","a cynical","a beautiful","a plucky","a sarcastic","a psychotic","a hard-bitten","a manipulative","an orphaned","a cosmopolitan","a chain-smoking","a cold-hearted","a warm-hearted","a sharp-shooting","an enchanted","a wealthy","a pregnant","a mentally unstable","a virginal","a brilliant","a disco-crazy","a provocative","an artistic"] + +she2 = ["tempestuous","Buddhist","foul-mouthed","nymphomaniac","green-skinned","impetuous","African-American","punk","hypochondriac","junkie","blonde","goth","insomniac","gypsy","mutant","renegade","tomboy","French-Canadian","motormouth","belly-dancing","communist","hip-hop","thirtysomething","cigar-chomping","extravagent","out-of-work","Bolivian","mute","cat-loving","snooty","wisecracking","red-headed","winged","kleptomaniac","antique-collecting","psychic","gold-digging","bisexual","paranoid","streetsmart"] + +she3 = ["archaeologist","pearl diver","mechanic","detective","hooker","femme fatale","former first lady","barmaid","fairy princess","magician's assistant","schoolgirl","college professor","angel","bounty hunter","opera singer","cab driver","soap star","doctor","politician","lawyer","nun","snake charmer","journalist","bodyguard","vampire","stripper","Valkyrie","wrestler","mermaid","single mother","safe cracker","traffic cop","research scientist","queen of the dead","Hell's Angel","museum curator","advertising executive","widow","mercenary","socialite"] + +she4 = ["on her way to prison for a murder she didn't commit.","trying to make a difference in a man's world.","with the soul of a mighty warrior.","looking for love in all the wrong places.","with an MBA from Harvard.","who hides her beauty behind a pair of thick-framed spectacles.","with the power to see death.","descended from a line of powerful witches.","from a family of eight older brothers.","with a flame-thrower.","with her own daytime radio talk show.","living on borrowed time.","who can talk to animals.","prone to fits of savage, blood-crazed rage.","who don't take no shit from nobody.","with a knack for trouble.","who believes she is the reincarnation of an ancient Egyptian queen.","fleeing from a Satanic cult.","on the trail of a serial killer.","with a birthmark shaped like Liberty's torch.","in the witness protection scheme.","from out of town.","from aristocratic European stock.","living homeless in New York's sewers.","with only herself to blame.","from beyond the grave","married to the Mob.","from the wrong side of the tracks.","from a secret island of warrior women.","from Mars.","with someone else's memories.","from a different time and place.","operating on the wrong side of the law.","who inherited a spooky stately manor from her late maiden aunt.","who dreams of becoming Elvis.","with a song in her heart and a spring in her step.","in the wrong place at the wrong time.","with an incredible destiny.","with the power to bend men's minds.","with an evil twin sister."] + +print "He's " + he1[a[0]] + " " + he2[a[1]] + " " + he3[a[2]] + " " + he4[a[3]], +print "She's " + she1[a[4]] + " " + she2[a[5]] + " " + she3[a[6]] + " " + she4[a[7]], +print "They fight crime!" diff --git a/bin/touchhtml b/bin/touchhtml new file mode 100755 index 0000000..aef0454 --- /dev/null +++ b/bin/touchhtml @@ -0,0 +1,87 @@ +#!/usr/bin/perl +# +# Globals +# +use vars qw/$deftext %opt /; + +# +# Command line options processing +# +sub init() +{ + use Getopt::Std; + my $opt_string = 'hpci:o:t:j:'; + getopts( "$opt_string", \%opt ) or usage(); + usage() if $opt{h}; +} + +# +# Message about this program and how to use it +# +sub usage() +{ + print STDERR << "EOF"; + +touchhtml -- Create a barebones HTML file + +usage: $0 [-hpc][-i ][-o ][-t ] + + -h : This (help) message + -p : Add <pre> tags + -c : Print "Content-type" at the start (for CGI) + -i FILE : Read body from given filename + -o FILE : Output to given filename + -t TITLE : Set the HTML <TITLE> field to given title + -j FILE : Include this JavaScript filename in the body + +EOF + exit; +} + +init(); + + +if (!$opt{o}) { + open(FILEH, ">-"); +} +else +{ + open(FILEH, ">$opt{o}") || die "Cannot open file for writing!"; +} + +if ($opt{c}) { + print "Content-type: text/html\n\n"; +} + +print FILEH <<FOO; +<HTML> +<HEAD> +<TITLE>$opt{t} + + +FOO +print FILEH "
\n" if $opt{p};
+if ($opt{i})
+{
+	open (INFILE, "<$opt{i}") || die "Cannot open file for reading!";
+	while ()
+	{
+		print FILEH;
+	}
+	close(INFILE);
+}
+elsif (!(-t STDIN))
+{
+	while ()
+	{
+		print FILEH;
+	}
+}
+print FILEH "
\n" if $opt{p}; +print FILEH "\n" if $opt{j}; +print FILEH < + +FOO + +close(FILEH); diff --git a/bin/unborkify b/bin/unborkify new file mode 100755 index 0000000..120f56d --- /dev/null +++ b/bin/unborkify @@ -0,0 +1,73 @@ +#!/usr/local/bin/perl + +use Getopt::Std; +getopts('u'); + +$user = (getpwuid($<))[0]; + +%maps = ( + 'a' => "\340\341\342\343\344\345", + 'c' => "\242\347", + 'd' => "\360", + 'e' => "\350\351\352\353", + 'i' => "\354\355\356\357", + 'n' => "\361", + 'o' => "\272\362\363\364\365\366\370", + 'p' => "\376", + 'q' => "\266", + 'u' => "\265\371\372\373\374", + 'x' => "\244\327", + 'y' => "\375", + 'A' => "\300\301\302\303\304\305", + 'B' => "\337", + 'C' => "\307\251", + 'D' => "\320", + 'E' => "\310\311\312\313", + 'I' => "\314\315\316\317", + 'L' => "\243", + 'N' => "\321", + 'O' => "\322\323\324\325\326", + 'P' => "\336", + 'R' => "\256", + 'U' => "\331\332\333\334", + 'Y' => "\245\335", + '!' => "\241", + '>' => "\273", + '<' => "\253", + '"' => "\250", + '+' => "\367", + '|' => "\246", + ',' => "\270", + '?' => "\277", + '0' => "\330", + '2' => "\262", + '3' => "\263" +); + +$| = 1; + +while (<>) { + CHAR: for $i (0..(length($_) - 1)) { + $c = substr($_,$i,1); + + # if ($c eq 'A' && substr($_,$i+1,1) eq 'E') { + # print "\306"; + # $skip = 1; next; + # } elsif ($c eq 'a' && substr($_,$i+1,1) eq 'e') { + # print "\346"; + # $skip = 1; next; + # } else { + # print((defined $maps{$c}) ? + # substr($maps{$c}, int rand(length($maps{$c})), 1) : $c); + # } + + for $x (keys %maps) { + if ($maps{$x} =~ /\Q$c/) { + print $x; + next CHAR; + } + } + + print $c; + } +} diff --git a/bin/vee b/bin/vee new file mode 100755 index 0000000..b7d9f09 --- /dev/null +++ b/bin/vee @@ -0,0 +1,8 @@ +#!/usr/bin/perl +open(OUTPIPE, "$ARGV[0]") || die; +while() +{ + print STDOUT $_; + print OUTPIPE $_; +} +close(OUTPIPE); diff --git a/bin/wd b/bin/wd new file mode 100755 index 0000000..ddc6e86 --- /dev/null +++ b/bin/wd @@ -0,0 +1,120 @@ +#! /usr/bin/perl -w +# +# wd - what doing? get/set your twitter.com status +# version 1.07, 2007-01-09 +# +# Copyright (c) 2007, Andrew J. Cosgriff, http://polydistortion.net/ +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# * The names of its contributors may not be used to endorse or +# promote products derived from this software without specific +# prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +########## +# +# Configuration: +# +# set your username (e-mail address) and password here. +# +# note that you'll need to put a backslash \ in front of the @-sign in your +# e-mail address. +# +my $username = ""; +my $password = ""; +########## +use strict; +use JSON; +use LWP; +use Getopt::Std; +use DateTime::Format::Strptime; + +my $ua = LWP::UserAgent->new; +$ua->credentials('twitter.com:80','Twitter API',$username,$password); + +my %opts = (); +getopts('pvs', \%opts); + +if (defined $opts{'p'}) { + $ua->env_proxy; +} + +if ((! defined $opts{'s'}) and ($#ARGV > 0)) { + print "[warning] hmm, are you sure you didn't mean to add a -s to that?\n\n"; +} + +if (defined $opts{'s'}) { + if ($#ARGV < 0) { + print "well, what are you doing?\n"; + exit 1; + } + + my $response = $ua->post('http://twitter.com/statuses/update.json', + [ "status" => join(' ',@ARGV) ]); + + die "Wrong content-type (",$response->content_type,") received - was expecting application/json\n" + unless $response->content_type =~ m/^application\/json/; + + my $status = jsonToObj($response->content); + my %user = %{$status}; + if (defined $opts{'v'}) { + print "status set to: ",$user{'text'},"\n"; + } +} else { + my $response = $ua->get('http://twitter.com/statuses/friends.json'); + + die "Can't get Twitter status: ", $response->status_line + unless $response->is_success; + + die "Wrong content-type (",$response->content_type,") received - was expecting application/json\n" + unless $response->content_type =~ m/^application\/json/; + + my $status = jsonToObj($response->content); + my $strp = new DateTime::Format::Strptime( + pattern => '%a %b %d %T %z %Y', + locale => 'en_AU', + time_zone => 'Australia/Melbourne', + ); + my %stati=(); + foreach my $userobj (@{$status}) { + my %user=%{$userobj}; + next if ((($#ARGV >= 0) and + ($user{screen_name} !~ m/$ARGV[0]/)) + or (! defined $user{status})); + + $stati{$user{screen_name}}{"text"} = $user{status}->{text}; + $stati{$user{screen_name}}{"rel"} = $user{status}->{relative_created_at}; + $stati{$user{screen_name}}{"date"} = DateTime::Format::Strptime::strftime("%s",$strp->parse_datetime($user{status}->{created_at})); + } + + foreach my $user (sort {$stati{$a}{"date"} cmp $stati{$b}{"date"};} keys %stati) { + print "$user ",$stati{$user}{text}," (",$stati{$user}{"rel"},")\n"; + } + +} + diff --git a/bin/wye b/bin/wye new file mode 100755 index 0000000..088bf81 Binary files /dev/null and b/bin/wye differ