Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit 53aeb02d303e42d58e7dfce24bbfafeb63fdee1d @bkudria committed Jul 5, 2008
Showing with 1,266 additions and 0 deletions.
  1. +437 −0 .bashrc
  2. +27 −0 .gitconfig
  3. 0 .hushlogin
  4. +15 −0 .inputrc
  5. +107 −0 .irbrc
  6. +21 −0 .nanorc
  7. +15 −0 .ssh/config
  8. +35 −0 .vimrc
  9. +24 −0 .xbindkeysrc
  10. +131 −0 bin/hosts.rb
  11. +454 −0 bin/unball
437 .bashrc
@@ -0,0 +1,437 @@
+#!/usr/bin/env bash
+
+if [[ -f /etc/bash_completion ]]; then
+ . /etc/bash.bashrc
+fi
+
+export PATH=$PATH:/home/bkudria/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/games:/var/lib/gems/1.8/bin
+OS=""
+DISTRO=""
+LOCATION=""
+
+OS=`uname`
+
+[[ -e /etc/issue ]] && DISTRO=`cat /etc/issue.net | head -n 1 | awk '{print $1 }'`
+
+if [[ "`domainname 2> /dev/null`" = "prvt.nytimes.com" ]] || [[ "`hostname -d`" = "prvt.nytimes.com" ]]; then
+ LOCATION="NYT"
+fi
+
+bind "set editing-mode emacs"
+bind "set keymap emacs"
+bind "set completion-ignore-case on"
+bind "set match-hidden-files off"
+bind "set show-all-if-ambiguous on"
+bind "set visible-stats on"
+
+set -o notify
+set -o emacs
+set -o noclobber
+
+# Distro/OS specific setters
+if [[ "$DISTRO" == "Debian" ]] || [[ "$DISTRO" == "Ubuntu" ]]; then
+ RCDIR="/etc/init.d/"
+fi
+
+if [ "$OS" = "FreeBSD" ]; then
+ LS_OPTIONS='-G'
+ RCDIR="/usr/local/etc/rc.d/ /etc/rc.d/"
+fi
+
+if [[ "$OS" = "Linux" ]]; then
+ LS_OPTIONS='--color=auto'
+fi
+
+
+function qwhich {
+ if [[ "$DISTRO" = "CentOS" ]]; then
+ which $@ 2> /dev/null
+ else
+ which $@
+ fi
+}
+
+if [[ "$LOCATION" = "NYT" ]]; then
+ export CVSROOT=":ext:bkudria@cvs.prvt.nytimes.com:/nytd/nytimes/src/cvs"
+ export CVS_RSH="ssh"
+ export SVN="http://svn.prvt.nytimes.com/svn"
+fi
+
+if [[ -x `qwhich hosts.rb` ]]; then
+ alias hosts='hosts.rb'
+fi
+
+if [[ -x `qwhich hosts` ]]; then
+ alias hosts='hosts'
+fi
+
+# User-dependent Settings
+if [[ -x `qwhich whoami` ]] && [[ "`whoami`" -eq "root" ]]; then
+ umask 022
+ export TMOUT=1200
+else
+ umask 033
+fi
+
+if [[ -x `qwhich inotail` ]]; then
+ alias tail='inotail'
+fi
+
+if [[ -x `qwhich bing` ]]; then
+ alias bandwidth='s bing localhost'
+fi
+
+if [[ -x `qwhich keychain` ]] && [[ $UID -ne 0 ]]; then
+ eval `keychain --inherit any-once --eval -Q -q --ignore-missing identity 209BE410`
+fi
+
+# General
+ # Functions
+ function hotpluginfo { udevinfo -a -p `udevinfo -q path -n $1`; }
+
+ function ifupdown { sudo ifdown $1; sudo ifup $1; }
+
+ function restart { killall $1; sleep 1s; $1; }
+
+ function common { history | awk '{print $9}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr ;}
+
+ function service { sudo $RCDIR$1 $2; }
+
+ function mcd { mkdir "$@" && cd "${!#}"; }
+
+ function cdl { cd "$@" && ls; }
+
+ function psg { ps aux | grep "[${1:0:1}]${1:1}"; }
+
+ export HOSTCOLORCODE="245"
+
+ if [[ -x `qwhich hosts` ]] && `qwhich hosts` &> /dev/null; then
+ export HOSTS_TYPE='binary'
+ else
+ if [[ -x `qwhich hosts.rb` ]] && [[ -x `qwhich ruby` ]]; then
+ export HOSTS_TYPE='script'
+ else
+ export HOSTS_TYPE='none'
+ fi
+ fi
+
+ function hosts
+ {
+ if [[ $HOSTS_TYPE == "binary" ]]; then
+ `qwhich hosts` "$@"
+ else
+ if [[ HOSTS_TYPE == 'script' ]]; then
+ `qwhich hosts.rb` "$@"
+ else
+ return $HOSTCOLORCODE
+ fi
+ fi
+ }
+
+
+ # Aliases
+ alias activeoptions='egrep -v "#|^ *$"'
+ alias su='su -p'
+ [[ -x `qwhich sudo` ]] && alias su='sudo -s'
+ [[ ! -x `qwhich sudo` ]] && function sudo { su -p -c "$*"; }
+ alias g='egrep'
+ alias count='grep -c'
+ alias p='ping'
+ [[ -e `qwhich htop` ]] && alias top='htop'
+ alias killall=pkill
+
+ alias s='sudo'
+
+ alias watchfile='tail -f'
+ [[ -x `qwhich rlwrap` ]] && alias watchfile='rlwrap tail -f'
+
+ alias syslog='sudo tail -f /var/log/everything/current'
+ [[ -x `qwhich loco` ]] && alias syslog='sudo tail -f /var/log/everything/current | loco'
+ alias netstat='sudo netstat -tpav'
+ alias du='ncdu .'
+ alias df='di -h'
+ alias ps='ps auxwww'
+ alias h='history'
+ alias ?="h | g $*"
+ alias ps?="psg"
+ alias x='exit'
+ alias leases='cat /var/lib/misc/dnsmasq.leases'
+ alias irb='irb --readline -r irb/completion'
+ alias ori='ri -T -f bs'
+ alias ri='qri'
+ alias cls='clear'
+ alias md='mkdir'
+ alias rd='rmdir'
+ alias cd..='cd ..'
+ alias up='cd ..'
+ alias cdo='cd ..'
+ alias ..='cd ..'
+ alias ...='cd ../..'
+ alias unix2dos='recode lat1..ibmpc'
+ alias dos2unix='recode ibmpc..lat1'
+
+ alias ssh='ssh -qAX'
+ alias newssh='ssh -S none'
+ alias sg='ssh greatbeyond.bsdwebsolutions.com'
+ alias stunnel='ssh -ND 1080 sartre'
+
+ alias more='less'
+ alias airnet='sudo pon sunysb'
+ alias hex="ruby -e 'printf(\"0x%X\n\", ARGV[0])'"
+ alias dec="ruby -e 'printf(\"%d\n\", ARGV[0])'"
+ alias bin="ruby -e 'printf(\"%bb\n\", ARGV[0])'"
+ alias word="ruby -e 'printf(\"0x%04X\n\", ARGV[0])'"
+
+ alias sml='rlwrap sml'
+ alias smlnj='sml'
+ alias uniq='sort | uniq'
+ alias httphead="curl -I"
+
+ # Security
+ alias rm='rm -i'
+ alias cp='cp -i'
+ alias mv='mv -i'
+ alias ln='ln -i'
+ alias mkdir='mkdir -p'
+
+ # Typos
+ alias chmdo='chmod'
+ alias sl='ls'
+ alias sll='ls'
+ alias lsl='ls'
+ alias l='ls'
+ alias tarx='tar x'
+ alias maek='make'
+ alias grpe='grep'
+ alias gpre='grep'
+ alias icfonfig='ifconfig'
+ alias ifocnfig='ifconfig'
+ alias e='$EDITOR'
+ alias nano='$EDITOR'
+ alias ss='sudo'
+ alias se='sudo $EDITOR'
+ alias vf='cd'
+ alias vp='cp'
+ alias nmv='mv'
+ alias mann='man'
+ alias nman='man'
+ alias nmann='man'
+ alias mb='mv'
+ alias nmplayer='mplayer'
+ alias les='less'
+ alias bashrc='source ~/.bashrc'
+ alias kate='kate -u'
+
+ # Git
+ alias gb='git branch'
+ alias gba='git branch -a'
+ alias gc='git commit -v'
+ alias gca='git commit -v -a'
+ alias gd='git diff | kompare -o -'
+ alias gl='git pull'
+ alias gp='git push'
+ alias gst='git status'
+
+ [[ -x `qwhich dog` ]] && alias cat='dog'
+ alias c='cat'
+
+
+ # Shell Options
+ shopt -s extglob
+ shopt -s progcomp
+ shopt -s histappend
+ shopt -s histreedit
+ shopt -s histverify
+ shopt -s cmdhist
+ shopt -s lithist
+ shopt -s cdspell
+ shopt -s no_empty_cmd_completion
+ shopt -s checkhash
+ shopt -s hostcomplete
+ shopt -s checkwinsize
+
+ # Apt-Get/dpkg tools - only on Debian
+ if [[ "$DISTRO" == "Debian" ]] || [[ "$DISTRO" == "Ubuntu" ]]; then
+
+ alias aptitude='s aptitude -y'
+ alias aget='aptitude install'
+ alias afix='aget -f'
+ alias aremove='aptitude remove'
+ alias apurge='aptitude purge'
+ alias aupdate='aptitude update'
+ alias aupgrade='aptitude safe-upgrade'
+ alias adistupgrade='aptitude dist-upgrade'
+ alias aconf='s dpkg-reconfigure'
+ alias ainstall='s dpkg -i'
+ alias anew='aupdate; adistupgrade'
+ alias astatus='apt-cache policy'
+ alias ainfo='apt-cache show'
+ alias adownload='aptitude download'
+ alias arefresh='s dpkg --clear-avail && s dpkg --forget-old-unavail'
+ alias afind='apt-cache search'
+ alias areinstall='aptitude reinstall'
+ alias afiles='wajig listfiles'
+
+ function aversion { dpkg -l $@ |grep ii| awk '{ print $3 }'; }
+ function acontents { dpkg-deb -c /var/cache/apt/archives/$1_`aversion $1`_*.deb; }
+ function apin { sudo echo "$1 hold" | sudo dpkg --set-selections; }
+ function aunpin { sudo echo "$1 install" | sudo dpkg --set-selections; }
+
+ function asearch { apt-cache show `apt-cache search $@ | sed s/\ -\ .*//g` | grep -v Priority | grep -v Section | grep -v Installed-Size | grep -v Maintainer | grep -v Architecture | grep -v Version | grep -v Replaces | grep -v Depends | grep -v Suggests | grep -v Conflicts | grep -v Filename | grep -v Size | grep -v MD5sum | grep -v Source | grep -v Provides | grep -v Description ; }
+ fi
+
+
+ if [[ $HOSTS_TYPE != 'none' ]]; then
+ export HASHSTRING="$HOSTNAME"
+
+ if [[ $OS = "SunOS" ]]; then
+ export HASHSTRING="`hostname`.`domainname`"
+ fi
+
+ if [[ $DISTRO = "CentOS" ]]; then
+ export HASHSTRING="`hostname -f`"
+ fi
+
+ export HOSTCOLORCODE=$(hosts "$HASHSTRING")
+ fi
+
+ export HOSTCOLORESCAPE="\[\033[38;5;${HOSTCOLORCODE}m\]"
+
+ # Prompt
+
+ bash_prompt()
+ {
+ local N="\[\033[0m\]" # unsets color to term's fg color
+
+ local UC=$HOSTCOLORESCAPE # user's color
+
+ local O="${UC}(${N}"
+ local C="${UC})${N}"
+
+ local D="${UC}-${N}"
+
+ [ $UID -eq "0" ] && O="${UC}[${N}"
+ [ $UID -eq "0" ] && C="${UC}]${N}"
+ [ $UID -eq "0" ] && D="${UC}-${N}"
+
+
+ local HO=$HOSTCOLORESCAPE
+ local HC=$N
+
+ PS1="${N}\n${O}${UC}\u${N}@${HO}\H${HC}:\w${C}${D}${O}\$?${C}${D}${O}"
+ PS2="${D}${O}"
+ }
+
+ # Change title & prompt
+ case "$TERM" in
+ xterm*|rxvt*)
+ PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME}:${PWD/$HOME/~}\007\""
+ ;;
+ *)
+ ;;
+ esac
+
+ export PROMPT_COMMAND="history -a; ${PROMPT_COMMAND}"
+
+ bash_prompt
+ unset bash_prompt
+
+
+
+# Misc
+ # Environment variables
+ export KDEDIR="/usr"
+ export QTDIR="/usr/share/qt3"
+ export PKG_CONFIG_PATH="/usr/lib"
+ export KDE_NO_IPV6=true
+ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/X11R6/lib/pkgconfig.
+ export GTK2_RC_FILES=$HOME/.gtkrc-2.0
+ export XAUTHORITY=/home/bkudria/.Xauthority
+ export HISTCONTROL=erasedups
+ export HISTSIZE=200000
+ export HISTFILESIZE=100000000
+ export HISTIGNORE="&:ls:&&"
+ export HISTTIMEFORMAT=%c%t
+ export EDITOR="nano"
+ export VISUAL="nano"
+ [[ -x kate ]] && export VISUAL="kate"
+ export GREP_COLOR="38;5;$HOSTCOLORCODE"
+ export ACK_COLOR_MATCH="green"
+ export ACK_COLOR_FILENAME="green"
+ export GREP_OPTIONS="--color=auto"
+ export CLICOLOR=1
+ export PAGER=less
+ export GPGKEY='209BE410'
+ export DEBFULLNAME='Benjamin Kudria'
+ export DEBEMAIL='ben@kudria.net'
+ [[ -x gem ]] && export RUBYOPT='rubygems'
+
+# [ -x /usr/bin/most ] && export PAGER=most && alias less=most
+
+ export LESS="iRwm"
+ export MOST_SWITCHES=""
+ export CLASSPATH="$CLASSPATH:/usr/share/java/junit.jar:/usr/share/java/ant.jar"
+
+ [[ "$TERM" == "xterm" ]] && [[ -x `qwhich setterm` ]] && setterm -blength 0 # Disable annoying beep (console)
+ [[ -x `qwhich xset` ]] && [[ $DISPLAY != "" ]] && xset b off # disable annoying beep (X)
+ ulimit -c unlimited # No limits.
+ [[ -x `qwhich lesspipe` ]] && eval `lesspipe` # Allow less to view *.gz etc. files.
+
+
+ # Completion
+
+ # If available, source the global bash completion file.
+ if [[ -f /etc/bash_completion ]]; then
+ source /etc/bash_completion
+ fi
+
+ [[ $HOSTS_TYPE != 'none' ]] && HOSTS_COMPLETE=$(hosts -h)
+ [[ -x `qwhich snippit` ]] && SNIPPIT_COMPLETE=$(snippit list)
+
+# complete -A alias alias unalias
+ complete -A command which qwhich s sudo tsocks
+ complete -A export export printenv
+ complete -A hostname ssh telnet ftp ncftp ping dig nmap scp
+ [[ $HOSTS_TYPE != 'none' ]] && complete -A hostname -o default -W "${HOSTS_COMPLETE[*]}" ssh telnet ftp ncftp ping dig nmap scp p
+ complete -W "${SNIPPIT_COMPLETE[*]}" snippit ks
+# complete -A helptopic help
+# complete -A job -P '%' fg jobs
+# complete -A setopt set
+# complete -A shopt shopt
+ complete -A signal kill killall
+# complete -A user su userdel passwd
+# complete -A group groupdel groupmod newgrp
+ complete -A directory cd rmdir
+
+ complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|m4v)' mplayer
+
+ # Service RC.d completion
+ SERVICE_COMPLETE=( $(`qwhich ls` $RCDIR | grep -v "\:" | uniq ) )
+ complete -A service -o default -W "${SERVICE_COMPLETE[*]}" service
+
+ # Colorized ls, with options
+ [[ -x `qwhich dircolors` ]] && eval `dircolors`
+ LS_COLORS="$LS_COLORS*.JPG=01;35:*.GIF=01;35:*.jpeg=01;35:*.pcx=01;35:*.png=01;35:*.pnm=01;35:*.bz2=01;31:*.mpg=01;38:*.mpeg=01;38:*.MPG=01;38:*.MPEG=01;38:*.m4v=01;038:*.mp4=01;038:*.swf=01;038:*.avi=01;38:*.AVI=01;38:*.wmv=01;38:*.WMV=01;38:*.asf=01;38:*.ASF=01;38:*.mov=01;38:*.MOV=01;38:*.mp3=01;39:*.ogg=01;39:*.MP3=01;39:*.Mp3=01;39"
+
+
+ export LS_OPTIONS="$LS_OPTIONS -p -l -h"
+ alias ls='ls $LS_OPTIONS'
+
+ # make less more friendly for non-text input files, see lesspipe(1)
+ [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
+
+ # Terminal settings
+ if ! [[ $TERM ]] ; then
+ eval `tset -s -Q`
+ case $TERM in
+ con*|vt100|linux|xterm)
+ tset -Q -e ^?
+ ;;
+ esac
+ fi
+
+ # Import local/private settings
+ if [[ -f ~/.bashrc.local ]]; then
+ . ~/.bashrc.local
+ fi
+
27 .gitconfig
@@ -0,0 +1,27 @@
+[user]
+ name = Benjamin Kudria
+ email = ben@kudria.net
+
+[core]
+ editor = nano
+ pager = less
+ whitespace = trailing-space,space-before-tab,indent-with-non-tab
+
+[color]
+ diff = auto
+ status = auto
+ branch = auto
+ interactive = auto
+ ui = auto
+
+[alias]
+ push-all = "!for i in $(git config --list | grep -E ^remote\\..+\\.url | sed 's/^remote\\.\\(.*\\)\\.url=.*/\\1/'); do git push $i master; done"
+
+ ci = commit
+ checkin = commit
+
+ co = checkout
+
+ lc = log ORIG_HEAD.. --stat --no-merges
+ llog = log --date=local
+ gitkconflict = !gitk --left-right HEAD...MERGE_HEAD
0 .hushlogin
No changes.
15 .inputrc
@@ -0,0 +1,15 @@
+set bell-style none
+
+"\e[B": history-search-forward
+"\e[A": history-search-backward
+
+$if Bash
+ #do history expansion when space entered
+ Space: magic-space
+$endif
+
+set show-all-if-ambiguous on
+
+set visible-stats on
+
+$include /etc/inputrc
107 .irbrc
@@ -0,0 +1,107 @@
+require 'rubygems'
+require 'wirble'
+require 'utility_belt'
+require 'what_methods'
+
+def e
+ edit(:kate)
+end
+
+IRB.conf[:SAVE_HISTORY] = 1000
+IRB.conf[:EVAL_HISTORY] = 1000
+
+# Prompts
+IRB.conf[:IRB_RC] = proc do |conf|
+ dashes = "-" * conf.irb_name.length
+ spaces = " " * conf.irb_name.length
+ conf.prompt_n = dashes + "-("
+ conf.prompt_i = "--( "
+ conf.prompt_s = dashes + "-( %l"
+ conf.prompt_c = dashes + "-( "
+ conf.return_format = dashes + "( %s )\n\n"
+end
+
+
+# Simple ri integration
+def ri(*names)
+ system("ri #{names.map {|name| name.to_s}.join(" ")}")
+end
+
+
+def time(times = 1)
+ require 'benchmark'
+ ret = nil
+ Benchmark.bm { |x| x.report { times.times { ret = yield } } }
+ ret
+end
+
+UtilityBelt::Themes.background(:dark)
+
+# from: http://raganwald.com/source/unfold.rb.html
+class Object
+ # unfold takes a "seed" argument and a incrementor. It returns an array. The
+ # first element of the array is the seed, every subsequentelement is the
+ # result of applying the incrementor to the previous element. so in
+ # pretentious quasi-math: result[n] = incrementor(result[n-1]). the array
+ # ends when the incrementor returns nil, so unfold(0) { |n| n+1 } is a bad
+ # idea in Ruby to add terminating conditions, use if not logic, because false
+ # does not terminate unfold.
+ #
+ # example: 10.unfold { |n| n-1 unless n == 1 }.inspect => [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
+ # example: 10.class.unfold(&:superclass).inspect => [Fixnum, Integer, Numeric, Object] # using Symbol#to_proc
+
+ # See also: NilClass#unfold
+ def unfold_slow options = {}, &incrementor
+ return [] unless options[:while].nil? || options[:while].to_proc.call(self)
+ transformed = options[:map] && options[:map].to_proc[self] || self
+ return [transformed] if options[:to] && options[:to].to_proc.call(self)
+ incrementor.call(self).unfold(options, &incrementor).unshift(transformed)
+ end
+
+ # from: http://weblog.raganwald.com/2007/11/really-simple-anamorphisms-in-ruby.html
+ # As above, but iterative, rather than recursive.
+ def unfold &block
+ result = [self]
+ x = block.call(self)
+ while not x.nil?
+ result.push x
+ x = block.call(x)
+ end
+ return result
+ end
+end
+
+class NilClass
+ # See: Object#unfold
+ def unfold options = {}, &incrementor
+ []
+ end
+end
+
+# local_methods shows methods that are only available for a given object.
+class Object
+ def local_methods
+ self.methods.sort - self.class.superclass.methods
+ end
+end
+
+# Simple regular expression helper
+# show_regexp - stolen from the pickaxe
+def show_regexp(a, re)
+ if a =~ re
+ "#{$`}|#{$&}|#{$'}"
+ else
+ "no match"
+ end
+end
+
+# Convenience method on Regexp so you can do
+# /an/.show_match("banana")
+class Regexp
+ def show_match(a)
+ show_regexp(a, self)
+ end
+end
+
+puts "Ruby #{RUBY_VERSION} #{RUBY_PLATFORM}, PID: #{$$}, #{Time.now}"
+
21 .nanorc
@@ -0,0 +1,21 @@
+include /usr/share/nano/html.nanorc
+include /usr/share/nano/java.nanorc
+include /usr/share/nano/c.nanorc
+include /usr/share/nano/nanorc.nanorc
+include /usr/share/nano/patch.nanorc
+include /usr/share/nano/perl.nanorc
+include /usr/share/nano/python.nanorc
+include /usr/share/nano/ruby.nanorc
+include /usr/share/nano/sh.nanorc
+include /usr/share/nano/tex.nanorc
+
+set autoindent
+set const
+set smarthome
+set smooth
+set tabsize 4
+set multibuffer
+set whitespace >_
+set nowrap
+unset tabstospaces
+unset mouse
15 .ssh/config
@@ -0,0 +1,15 @@
+Compression yes
+ForwardAgent yes
+ForwardX11Trusted yes
+HashKnownHosts yes
+
+IdentityFile ~/.ssh/identity
+IdentityFile ~/.ssh/id_rsa
+
+GSSAPIAuthentication no
+GSSAPIKeyExchange no
+GSSAPIDelegateCredentials no
+
+Host *
+ ControlPath ~/.ssh/master-%l-%r@%h:%p
+ ControlMaster auto
35 .vimrc
@@ -0,0 +1,35 @@
+set nocompatible " enable non-compatible options
+set mouse=a " mouse support
+set nu " line numbering
+set wrap " wrap long lines
+set bg=dark " dark background
+set stal=2 " tab line
+set mousef " mouse focus
+set mousem=popup " popup on right click
+set gfn=Consolas,Terminus,mono " fonts
+set smd " show mode
+set vb " visual bell
+set ts=2 " <tab> is 2 wide
+set sw=2 " 2 spaces for indent
+set nosta " turn off smarttab
+set sts=0 " insert no spaces
+set noet " don't expand <tab>
+set ai " auto-indent
+set si " smart indent
+set ml " use modelines
+set ar " re-read modified file automatically
+set fs " sync file to disk after writing
+set hi=10000000 " keep a lot of history
+set lpl " load plugins
+set debug=msg " show errors
+set showcmd " show incomplete commands
+
+
+" Turn on colors if they are available
+if &t_Co > 2 || has("gui_running")
+ syntax on
+ set hlsearch
+endif
+
+" attempt to guess file, load appropriate plugin, and use appropriate indent
+filetype plugin indent on
24 .xbindkeysrc
@@ -0,0 +1,24 @@
+#keystate_numlock = enable
+#keystate_scrolllock = enable
+#keystate_capslock = enable
+
+"keyout {left}"
+ b:7
+
+"keyout {right}"
+ b:6
+
+"dcop kicker kicker toggleShowDesktop"
+ b:8
+
+"toggle-kmail"
+ b:9
+
+"xte "keydown Control_L" "key XF86AudioLowerVolume" "keyup Control_L""
+ b:15
+
+"xte "keydown Control_L" "key XF86AudioRaiseVolume" "keyup Control_L""
+ b:13
+
+"keyout "{alt}1{alt}""
+ b:17
131 bin/hosts.rb
@@ -0,0 +1,131 @@
+#!/usr/bin/env ruby
+
+require 'optparse'
+
+class Array
+ def flatten_ranges
+ self.map {|r| r.to_a}.flatten
+ end
+end
+
+@options = {:color => :light}
+
+@hostnames =
+{
+ 'laotzu' => 220,
+ 'kudria.net' => nil,
+ 'sartre' => nil,
+ 'weyl.ams.sunysb.edu' => nil,
+ 'seawulf.stonybrook.edu' => nil,
+ 'sparky.ic.sunysb.edu' => nil,
+ 'greatbeyond.bsdwebsolutions.com' => 220,
+ 'galaxy.ams.sunysb.edu' => nil,
+ 'olympus.ams.sunysb.edu' => nil,
+}
+
+@nyt_hostnames =
+{
+ 'app1.prvt.nytimes.com' => 149,
+ 'dapi.prvt.nytimes.com' => nil,
+ 'cvs.prvt.nytimes.com' => nil,
+ 'ddeploy.prvt.nytimes.com' => nil,
+ 'dmysql1.prvt.nytimes.com' => nil,
+ 'svn.prvt.nytimes.com' => nil,
+ 'dsvn.prvt.nytimes.com' => nil,
+}
+
+@galaxy_hostnames =
+{
+ 'sirius' => 179,
+ 'sagittarius' => nil,
+ 'starzero' => 202,
+ 'centauri01' => nil,
+ 'centauri02' => nil,
+ 'tauri01' => nil,
+ 'tauri02' => nil,
+ 'aurigae' => nil,
+ 'aquilae' => nil,
+}
+
+@hostnames.merge! @galaxy_hostnames
+@hostnames.merge! @nyt_hostnames
+
+@lightlist = [66..66, 131..131, 143..146].flatten_ranges
+@light_colors = ([20..21, 25..51, 56..57,
+ 61..87, 90..231].flatten_ranges - @lightlist).reverse
+
+@dark_colors = [16..33, 52..71, 88..100,
+ 124..137, 160..178, 196..208].flatten_ranges
+
+@scary_light_colors = [124..125, 130..130,
+ 160..161, 166..167, 172..172, 196..197,
+ 202..203, 208..210, 220..221].flatten_ranges
+
+@scary_dark_colors = [124..125, 160..162,
+ 166..168, 196..198, 202..204, 208..209].flatten_ranges
+
+def hash_chars(string)
+ string.split('').inject{|sum, char| (sum.to_i ^ char[0]) % 131 }
+end
+
+def hostname_to_color(hostname)
+ if @hostnames[hostname]
+ if @options[:scary]
+ colors = @options[:color] == :light ? @scary_light_colors : @scary_dark_colors
+ colors[hash_chars(hostname) % colors.length]
+ else
+ @hostnames[hostname]
+ end
+ else
+ if @options[:scary]
+ colors = @options[:color] == :light ? @scary_light_colors : @scary_dark_colors
+ else
+ colors = @options[:color] == :light ? @light_colors : @dark_colors
+ end
+ colors[hash_chars(hostname) % colors.length]
+ end
+end
+if ARGV.first =~ /-/
+ OptionParser.new do |opts|
+ opts.banner = "Usage: #{__FILE__} [@options] string_to_hash"
+
+ opts.on("-l", "--light", "Displays a light color (for dark color schemes) (default)") do
+ @options[:color] = :light
+ end
+
+ opts.on("-d", "--dark", "Displays a dark color (for light color schemes)") do
+ @options[:color] = :dark
+ end
+
+ opts.on("-s", "--scary-color", "Picks from a list of scary red/yellow/orange colors only") do
+ @options[:scary] = true
+ end
+
+ opts.on("-h", "--hostnames", "Lists all saved hostnames, suitable for parsing by bash completion") do
+ @options[:hostnames] = true
+ end
+
+ opts.on("-e", "--[no-]escape-code", "Prints xterm escape code instead of just numeric color code") do |escape|
+ @options[:escape] = escape
+ end
+ end.parse!
+end
+
+if @options[:hostnames]
+ print @hostnames.keys.join(' ')
+else
+ hostname = ARGV.first
+
+ if hostname.nil?
+ puts "Please specify a hostname"
+ exit
+ end
+
+ colorcode = hostname_to_color(hostname).to_s
+
+ if @options[:escape]
+ print '\[\033[38;5;' + colorcode + 'm\]'
+ else
+ puts colorcode
+ end
+end
454 bin/unball
@@ -0,0 +1,454 @@
+#!/usr/bin/env bash
+# unball
+# Version 0.2.10 ($Revision$)
+# Copyright 2005, 2006 Stephan Sokolow
+#
+# See the README file in the distribution archive for details.
+# If unball came pre-installed, the archive can be obtained from http://www.ssokolow.com/
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+MY_VERSION="0.2.10" # For easy change of the version number provided by --version
+
+if grep "GNU tar" <<< `tar --version` > /dev/null ; then TAR_OPTS="--no-same-permissions"; fi
+
+FILE_OPTS="-binN"
+file -binNr /bin/sh &> /dev/null && FILE_OPTS="-binNr"
+file -binNpr /bin/sh &> /dev/null && FILE_OPTS="-binNpr"
+
+# Prefer p7zip when installed. (support for bzip2-compressed zip files)
+if which 7z &> /dev/null; then UNZIPPER="7z x"
+elif which 7za &> /dev/null; then UNZIPPER="7za x"
+else UNZIPPER="unzip -q"
+fi
+
+# Support the renamed binary from the Gentoo Sunrise ebuild for unace.
+if which unace-bin &> /dev/null; then UNACE="unace-bin"
+else UNACE="unace"
+fi
+
+function exists() { type "$@" &> /dev/null ; }
+function isprog() { which "$@" &> /dev/null ; }
+function lower() { tr [:upper:] [:lower:] <<< "$@"; }
+function pathjoin() { ([[ "$2" != /* ]] && echo "$1"/"$2") || echo "$2"; }
+function pathsplit() { grep -Eo "[^/]*$" <<< "$@"; }
+function sizeInKiB() { `du -k "$FILE" | grep -oE "^[0-9]*"`; } #Note: Old OSX versions don't have grep -o.
+function abspath() { (exists realpath && realpath -s "$@") || (exists readlink && readlink -f "$@") || pathjoin "`pwd`" "$@"; }
+
+function extract_cab() {
+ echo "Attempting to extract CAB archive. (Microsoft or InstallShield Cabinet)"
+ (exists cabextract && call cabextract "" "$2") ||
+ (exists unshield && call unshield "" "$2") ||
+ (echo "Unable to extract $2. Ensure that both cabextract and unshield are installed." && return 1)
+}
+
+function extract_exe() {
+ echo "Attempting to extract EXE file without running it's untrusted executable code..."
+ (exists unzip && call unzip "" "$2") ||
+ (exists 7z && call 7z "x" "$2") ||
+ (exists arj && call arj x -y "$2") ||
+ (exists unrar && call unrar "x -y -p-" "$2")
+ # unrar and lha don't have proper return values with regards to "cannot extract..."
+ # unace just can't be called anything earlier than last because it's unreliable
+ [ "`ls -1`" = "" ] && (exists lha && call lha x "$2")
+ [ "`ls -1`" = "" ] && (exists $UNACE && call $UNACE "x -y" "$2" )
+ [ "`ls -1`" = "" ] && echo "Cannot extract $2. If you are certain it is a self-extracting archive and that it does not contain malicious code, try running it inside Wine" && return 1 # Unrar and lha always say "everything's dandy" so we have to check manually.
+ return 0
+}
+
+function extract_gbzip() {
+ TARGETFILE=$(pathjoin "$TEMPTARGET" $(pathsplit "$2"))
+ exists $1 || (echo "ERROR: Cannot find unarchiver: $1" && return 1)
+ cp "$2" "$TARGETFILE" || (echo "ERROR: Cannot create temporary copy of $2" && return 1)
+ if [ ".${TARGETFILE##*.}" != ".gz" ] && [ "$1" = "gunzip" ]; then
+ call $1 "-S .${TARGETFILE##*.}" "$TARGETFILE" || (echo "ERROR: Decompressor $1 failed." && return 1)
+ elif [ `file $FILE_OPTS $TARGETFILE` = "application/x-compress" ] && [ ".${TARGETFILE##*.}" != ".Z" ] &&
+ [ ".${TARGETFILE##*.}" != ".z" ]; then
+ "$1" -c "$TARGETFILE" > "$TARGETFILE.out"
+ rm "$TARGETFILE"
+ else
+ call $1 "" "$TARGETFILE" || (echo "ERROR: Decompressor $1 failed." && return 1)
+ fi
+}
+
+function extract_rpm() {
+ if exists rpm2cpio && exists cpio; then
+ rpm2cpio "$2" | cpio --quiet -id || (echo "ERROR: rpm2cpio or cpio error" && return 1)
+ elif exists rpm2targz && exists tar && (exists gunzip || exists gzip); then
+ call rpm2targz "$2" || (echo "ERROR: Unknown rpm2targz failure" && return 1)
+ TARGZ="${2%.*}.tar.gz"
+ call tar xzf "$TARGZ" || (echo "ERROR: Unknown failure extracting $TARGZ" && return 1)
+ call rm "$TARGZ" || (echo "ERROR: Could not remove $TARGZ" && return 1)
+ unset TARGZ
+ else
+ echo "ERROR: RPM extraction requires either rpm2cpio with cpio, or rpm2targz with a gzip-friendly tar command."
+ return 1
+ fi
+ return 0
+}
+
+function extract_sit() {
+ if ! exists unstuff; then
+ PATH="$PATH:/opt/stuffit/bin"
+ export PATH
+ fi
+ (exists unstuff && call unstuff "--destination=." "`sed \"s@/[^/]*@../@g\" <<< \`pwd\``$1") || (echo "ERROR: Could not find Stuffit Expander" && return 1)
+}
+
+function extract_adf() {
+ if [ "$1" = "adz" ]; then
+ extract_gbzip gunzip "$2"
+ TGT="${2%.adz}.adf"
+ else
+ TGT="$2"
+ fi
+
+ (exists unadf && call unadf "$TGT") || (exists readdisk && call readdisk "$TGT") || (echo "ERROR: Could not find unadf or readdisk" && return 1);
+}
+function extract_dms() { (exists xdms && call xdms u "$2") || (exists undms && call undms "$2" "${2%.*}.adf" ) || (echo "ERROR: Could not find xDMS or undms" && return 1); }
+
+function decode_macbin() { (exists macunpack && call macunpack -f "$2") || (exists unstuff && call unstuff "--destination=." "`sed \"s@/[^/]*@../@g\" <<< \`pwd\``$2") || (echo "ERROR: Could not find macunpack or Stuffit Expander" && return 1); }
+function decode_binhex() { (exists uudeview && call uudeview -i "$1") || (exists unstuff && call unstuff "--destination=." "`sed \"s@/[^/]*@../@g\" <<< \`pwd\``$1") || (echo "ERROR: Could not find UUDeView or Stuffit Expander" && return 1); }
+function decode_uu() { (exists uudecode && call uudecode "" "$1") || (exists uudeview && call uudeview -i "$1") || (echo "ERROR: Could not find UUDecode or UUDeView" && return 1); }
+function decode_xx() { (exists xxdecode && call xxdecode "" "$1") || (exists uudeview && call uudeview -i "$1") || (echo "ERROR: Could not find XXDecode or UUDeView" && return 1); }
+function decode_ync() { (exists ydecode && call ydecode "" "$1") || (exists yydecode && call yydecode "" "$1") ||(exists uudeview && call uudeview -i "$2") || (echo "ERROR: Could not find YDecode, yydecode, or UUDeView" && return 1); }
+
+# A centralized method of implementing the quiet/verbose switch.
+function call() {
+ if [ "$verbose" = 1 ] || [ "$1" = "gunzip" ] || [ "$1" = "bunzip" ] || [ "$1" = "cpio" ]; then
+ # Reminder: This cannot be compressed using && and || because $1 may return a nonzero value.
+ if [ -n "$2" ]; then
+ $1 $2 "$3"
+ else
+ $1 "$3"
+ fi
+ else
+ if [ "$1" = "$UNACE" ] || [ "$1" = "lzop" ]; then
+ if [ -n "$2" ]; then
+ $1 $2 "$3" < /dev/random &> /dev/null
+ else
+ $1 "$3" < /dev/random &> /dev/null
+ fi
+ else
+ if [ -n "$2" ]; then
+ $1 $2 "$3" &> /dev/null
+ else
+ $1 "$3" &> /dev/null
+ fi
+ fi
+ fi
+}
+
+# What will eventually be the only call command
+function new_call() {
+ if [ "$verbose" = 1 ] || [ "$1" = "gunzip" ] || [ "$1" = "bunzip" ] ||
+ [ "$1" = "cpio" ] || [ "$1" = "uncompress" ]; then
+ "$@"
+ else
+ if [ "$1" = "$UNACE" ]; then
+ "$@" < /dev/random &> /dev/null
+ else
+ "$@" &> /dev/null
+ fi
+ fi
+}
+
+# This is the best bash equivalent I can think of to Python's try/except or Java's try/catch. (I forget what Perl's version is called)
+function really_extract() {
+ # Usage: really_extract archive_tool arguments file targetDir
+ [[ $# != 4 ]] && echo "BUG #002: Invalid number of arguments passed to really_extract()" && return 1
+
+ CMD="$1"
+
+ SRCFILE="${3##*/}"
+ TARGET=`pathjoin "$OUTDIR" "${SRCFILE%.*}"`
+
+ if [ "$TARGET" = "`pathjoin \"$OUTDIR\" \"$SRCFILE\"`" ]; then # The source file is extensionless
+ TARGET="$TARGET.out"
+ fi
+
+ if [ -e "$TARGET" ]; then
+ echo "Target dir \"$TARGET\" exists. Aborting for this file."
+ return 2
+ fi
+
+ TEMPTARGET=`mktemp -td unball.XXXXXX` || return 2
+ cd "$TEMPTARGET" || return 3
+ exists "$1" || return 4
+
+ ARGS=${2//\%OUTDIR\%/$TEMPTARGET}
+ ((isprog "$CMD" && call "$CMD" "$ARGS" "$3") || ("$CMD" "$ARGS" "$3")) || return 5
+
+ # The check for nested tar archives
+ if [[ "$TARGET" = *.tar ]] && [ -f "$TARGET" ]; then
+ echo "Found nested tar archive. Unballing...";
+ (tar xf "$TARGET" || return 5) && (rm "$TARGET" || return 7)
+ fi
+ [[ "$TARGET" = *.tar ]] && TARGET="${TARGET%.*}"
+ unset TARTARGET
+
+ # Compensate for an idiocy I discovered in unball which can create files with 000 permissions.
+ chmod -R u+r *
+
+ # If there are no more than 3 entries (including . and ..) then just move the contents
+ if [ `ls -a "$TEMPTARGET" | wc -l` -le 3 ]; then
+ mv * "$OUTDIR" || return 6
+ else
+ mv "$TEMPTARGET" "$TARGET" || return 6
+ fi
+
+ cd "$CURRDIR" || return 3
+ [ -a "$TEMPTARGET" ] && (rmdir "$TEMPTARGET" || return 7)
+ return 0
+}
+
+function extract() {
+ # Usage: extract archive_tool arguments file type_description
+ # Return values for really_extract:
+ # 0 - Extracted OK
+ # 1 - A bug trap was triggered.
+ # 2 - Could not make temp dir
+ # 3- Could not change directories
+ # 4 - Could not find requested unarchiving tool
+ # 5 - Archive tool returned an error
+ # 6 - Could not move files to target dir
+ # 7- Could not delete temporary files/dirs.
+ [[ $# != 4 ]] && echo "BUG #001: Invalid number of arguments passed to extract()" && return 1
+ CURRFILE=`abspath "$3"`
+
+ echo "Found $4, unballing $3..."
+ really_extract "$1" "$2" "$CURRFILE" "$OUTDIR"
+ RETURNCODE="$?"
+ if [ $RETURNCODE != 0 ]; then
+ # Clean up after the failed extraction
+ cd "$CURRDIR"
+ rm -rf "$TEMPTARGET"
+ [ $RETURNCODE = 6 ] && [ ! -f "$TARGET" ] && rm -rf "$TARGET"
+
+ [ $RETURNCODE = 4 ] && echo "ERROR: Required archiving tool ($1) not found."
+ echo "ERROR: Could not extract $3 (Error code: $RETURNCODE)"
+ return $RETURNCODE
+ else
+ return 0
+ fi
+}
+
+function show_help() {
+ echo "Usage: $0 [options] archive ..."
+ echo "Extract one or more archives, given only the filename, while ensuring they won't make a mess."
+ echo
+ echo "Options:"
+ echo " -d/--dir TARGET Set the target directory for extraction"
+ echo " -D/--samedir Use the source directory as the target"
+ echo " -v/--verbose Show status output from the decompressors"
+}
+
+function show_version() {
+ echo "unball (ssokolow's) $MY_VERSION"
+}
+
+# Moving this into it's own function is the first step towards recursive support.
+function extractify() {
+ FILE="$1"
+ if [ "$samedir" = 1 ]; then
+ OUTDIR=$(abspath "$FILE")
+ OUTDIR="${OUTDIR%/*}"
+ fi
+ if [ -f "$FILE" ]; then
+ case `lower "$FILE"` in
+ # These silently ignore common formats which an "unball *" would otherwise generate an error message for.
+ *.txt|*.htm|*.html|*.shtm|*.shtml) [ "$verbose" = 1 ] && echo "Skipping text/html document: $FILE";;
+ *.mp3|*.ogg|*.flac|*.wav|*.shn|*.m4a|*.aac|*.ac3|*.mpc|*.wma) [ "$verbose" = 1 ] && echo "Skipping waveform audio file: $FILE";;
+ *.mod|*.stm|*.s3m|*.xm|*.it|*.mo3|*.mid|*.spc|*.gym|*.vgm|*.psf|*.sid|*.nsf|*.hsd) [ "$verbose" = 1 ] && echo "Skipping non-waveform audio file: $FILE";;
+
+ # The universal nested tar code would handle these, but gunzip and bunzip delete the compressed file on success.
+ # ...and a lot of people don't like that so we'll use tar's built-in support for input piping.
+ *.tar.bz2|*.tbz|*.tbz2) extract tar xjf "$FILE" "bzipped tar archive";;
+ *.tar.gz|*.tgz) extract tar xzf "$FILE" "gzipped tar archive";;
+ *.tar.z|*.taz|*.tz) extract tar xzf "$FILE" "compressed tar archive";;
+
+ # Let's take advantage of the fact that Stuffit Expander automatically handles BinHex and MacBinary
+ *.sit|*.sit.bin|*.sit.hqx) extract extract_sit "" "$FILE" "Stuffit archive";;
+ *.sea|*.sea.bin|*.sea.hqx) extract extract_sit "" "$FILE" "Stuffit Self-Extracting archive";;
+ *.sitx) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently a StuffitX archive. As of this writing, there is no tool in the Gentoo Portage tree which can extract such files and the author of unball is too lazy to install one manually without a request from a user.";;
+
+ *.7z) extract 7z "x -o%OUTDIR%" "$FILE" "7zip archive";;
+ *.ace) extract "$UNACE" "x -y" "$FILE" "ace archive";;
+ *.adf) extract extract_adf "adf" "$FILE" "Amiga ADF disk image";;
+ *.adz) extract extract_adf "adz" "$FILE" "GZipped Amiga ADF disk image";;
+ *.alz) extract unalz "" "$FILE" "ALZip Archive";;
+ *.a | *.ar) extract ar x "$FILE" "Potential ar archive";;
+ *.arc) extract arc x "$FILE" "arc archive";;
+ *.arj) extract arj "x -y" "$FILE" "arj archive";;
+ *.atr) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently an Atari ATR disk image. Unball doesn't support it yet, but apparently atool can extract it.";;
+ *.b64|*.mim) extract uudeview -ib "$FILE" "Base64-encoded file";;
+ *.bh) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently a BlakHole archive, but the author of unball could barely find any non-Linux programs which can handle this format. Supporting it is currently beyond the capabilities of unball.";;
+ *.bin) extract extract_macbin "" "$FILE" "Potential MacBinary-encoded file";;
+ *.bz2) extract extract_gbzip bunzip2 "$FILE" "bzip2-compressed file";;
+ *.bzf) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a BioWare BioZip file. Until unball gains support, you can directly use the biounzip tool to extract these.";;
+ *.cab) extract extract_cab "" "$FILE" "Microsoft or InstallShield 'cabinet'";;
+ *.cbr) extract unrar "x -y -p-" "$FILE" "RAR-compressed comic bundle";;
+ *.cbz) extract unzip "" "$FILE" "ZIP-compressed comic bundle";;
+ *.ccd) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is a CloneCD image. It can be converted to a standard ISO9660 CD image using ccd2iso.";;
+ *.cp) extract cpio "--force-local --quiet -idI" "$FILE" "cpio archive";;
+ *.cpio) extract cpio "--force-local --quiet -idI" "$FILE" "cpio archive";;
+ *.cpt) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently a Compact Pro (A.K.A. Compactor) archive. At this time, the unball author knows of no PackIt extractor for non-Macintosh platforms.";;
+ *.dar) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a DAR archive. DAR is a Linux backup tool and unball does not currently support extraction of DAR archives. If you ever see this message, report it to me and I'll consider that motivation enough to add support.";;
+ *.deb) extract ar x "$FILE" "Debian Linux package";;
+ *.dgc) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a DGCA archive, but since the only known site is in Japanese, the author of unball cannot tell much beyond the fact that the only complete tool seems to be Windows-only.";;
+ *.dms) extract decode_dms "" "$FILE" "DMS-packed ADF disk image";;
+ *.dmg) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is an Apple MacOS X disk image. To access it's contents, mount it using a loopback device. It's just an HFS, HFS+, UFS, or other Linux-readable filesystem in a file.";;
+ *.dz) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a DZip archive. Until unball gains support, you can directly use the dzip tool (http://speeddemosarchive.com/dzip/) to extract these.";;
+ *.ear) (exists jar && extract jar xf "$FILE" "potential Java Enterprise Archive (.ear)") || extract unzip "" "$FILE" "Potential Java Enterprise Archive (.ear)";;
+ *.egg) extract unzip "" "$FILE" "Python install package (egg)";;
+ *.exe) extract extract_exe "" "$FILE" "Potential Windows self-extracting archive";;
+ *.gca) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a GCA archive, but since the only known site is in Japanese, the author of unball cannot tell much beyond the fact that the only complete tool seems to be Windows-only.";;
+ *.gcf) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a WinXComp Grouped Compressed File, but odds are it's a Half-Life Game Cache File. Either way, there's no Linux tool to extract it.";;
+ *.gz) extract extract_gbzip gunzip "$FILE" "gzipped file";;
+ *.hqx|*.bhx) extract decode_binhex "" "$FILE" "BinHex-encoded file";; #UNTESTED for lack of a non-stuffit BinHex file.
+ *.ipk) extract tar xzf "$FILE" "itsy package";;
+ *.iso) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is an ISO9660 CD or DVD image. To access it's contents, mount it using a loopback device, or burn it to a disc.";;
+ *.j | *.jar) (exists jar && extract jar xf "$FILE" "jar archive") || extract unzip "" "$FILE" "jar archive";; # A jar is just a zip file with a different extension and a specific folder layout inside
+ *.kgb) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be an archive. If so, it can be extracted using the KGB archive tool.";;
+ *.lzh | *.lha) extract lha x "$FILE" "lzh archive";;
+ *.lzo) extract lzop -x "$FILE" "lzop archive";;
+ *.lzx) extract unlzx -x "$FILE" "Amiga LZX archive";;
+ *.msi) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is a Microsoft Installer package. At this time, the unball author knows of no MSI extraction method for Linux aside from running them inside Wine.";;
+ *.pak) extract unzip "" "$FILE" "Potential Quake level (.pak)";;
+ *.partimg) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is a PartImage file. It can be restored to an empty partition using the PartImage tool.";;
+ *.pit) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently a PackIt archive. At this time, the unball author knows of no PackIt extractor for non-Macintosh platforms.";;
+ *.pk3) extract unzip "" "$FILE" "Quake 3 level (.pk3)";;
+ *.pq6) extract paq6 "" "$FILE" "PAQ6 archive";;
+ *.rar) extract unrar "x -y -p-" "$FILE" "rar archive";;
+ *.rk) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently a WinRK archive. However, it seems that only the proprietary WinRK tool for Windows can extract these. Maybe you could run it inside Wine?";;
+ *.rpm) extract extract_rpm "" "$FILE" "RPM Package";;
+ *.rsn) extract unrar "x -y -p-" "$FILE" "RAR-compressed SNES music (spc) set";;
+ *.rz) extract extract_gbzip runzip "$FILE" "rzip-compressed file";;
+ *.sfark) extract sfarkxtc "" "$FILE" "sfArk-compressed SoundFont set";;
+ *.sfpack) DELAYEDMESSAGES="$DELAYEDMESSAGES\nFOUND: SFPack-compressed SoundFont set. unball does not handle these because there is no native Linux extraction tool for them. Please use the SFPack extractor for Windows from inside Wine.";;
+ *.sh) [ `sizeInKiB "$FILE"` -ge 512 ] && DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is unusually large for a shell script. It is probably a self-extracting archive. For security reasons, it was not executed automatically.";;
+ *.shar) DELAYEDMESSAGES="$DELAYEDMESSAGES\nFOUND: Shell Archive. Because there is no reliable way to extract these without executing them, please run \"sh $FILE\" manually if you really want to extract it.";;
+ *.slp) extract alien -g "$FILE" "Stampede Linux slp package";; #Untested for lack of a .slp file
+ *.sqx) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is apparently a Squeez archive (.sqx) but as of this writing, there is no known Linux tool which can extract Squeez files. However, the format is detailed at http://www.sqx-archiver.org/ and you can probably run the Squeez extractor for DOS or Windows inside Wine.";;
+ *.tar) extract tar xf "$FILE" "tar archive";;
+ *.umod) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is probably an Unreal Tournament umod archive. Until unball gains support, you can directly use the umod tool (from umodpack) to extract these.";;
+ *.uu | *.uue) extract decode_uu "" "$FILE" "UUEncoded file";;
+ *.uz2) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be an Unreal Tournament 2003/2004 resource archive. Until unball gains support, you can directly use the uz2unpack tool to extract these.";;
+ *.war) (exists jar && extract jar xf "$FILE" "Potential Java Web Archive (.war)") || extract unzip "" "$FILE" "Potential Java Web Archive (.war)";;
+ *.xar) extract xar -xf "$FILE" "Potential XAR archive";;
+ *.xpi) extract unzip "" "$FILE" "XPI install package";;
+ *.xx | *.xxe) extract decode_xx "" "$FILE" "XXEncoded file";;
+ *.ync) extract decode_ync "" "$FILE" "yEncoded file";;
+ *.zip) extract $UNZIPPER "$FILE" "Zip archive";;
+ *.zoo) extract zoo -extract "$FILE" "zoo archive";;
+ *.z) extract extract_gbzip uncompress "$FILE" "UNIX compressed file";; #UNTESTED
+ *.zz) DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE may be a ZZip archive. The code for ZZip is GPLed, but there appears to only be the Windows tool available..";;
+ *.*_) extract extract_gbzip msexpand "$FILE" "Microsoft compress.exe-packed file";;
+ *) echo "Unrecognized extension for $FILE. Attempting to determine type using file header..."
+ case `file $FILE_OPTS "$FILE"` in
+ "application/java-archive") (exists jar && extract jar xf "$FILE" "jar archive") || extract unzip "" "$FILE" "jar archive";;
+ "application/mac-binhex40") extract decode_binhex "" "$FILE" "BinHex-encoded file";;
+ "application/x-7z-compressed") extract 7z x "$FILE" "7zip archive";;
+ "application/x-ace") extract "$UNACE" "x -y" "$FILE" "ace archive";;
+ "application/x-ar"| "application/x-archive") extract ar x "$FILE" "ar archive";;
+ "application/x-arc"*) extract arc x "$FILE" "arc archive";;
+ "application/arj"|"application/x-arj") extract arj "x -y" "$FILE" "arj archive";;
+ "application/x-bcpio") extract cpio "--force-local --quiet -idI" "$FILE" "binary cpio archive";;
+ "application/bzip2"|"application/x-bz2"|"application/x-bzip"|"application/x-bzip2") extract extract_gbzip bunzip2 "$FILE" "bzip2-compressed file";;
+ "application/cab") extract extract_cab "" "$FILE" "Microsoft or InstallShield 'cabinet'";;
+ "application/x-compress"|"x-compress") extract extract_gbzip uncompress "$FILE" "UNIX compressed file";;
+ "application/x-compressed") extract tar xzf "$FILE" "gzipped tar archive";;
+ "application/x-cpio") extract cpio "--force-local --quiet -idI" "$FILE" "cpio archive";;
+ "application/x-deb") extract ar x "$FILE" "Debian Linux package";;
+ "application/x-dgca-compressed") DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is a DGCA archive, but since the only known site is in Japanese, the author of unball cannot tell much beyond the fact that the only complete tool seems to be Windows-only.";;
+ "application/x-gca-compressed") DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is a GCA archive, but since the only known site is in Japanese, the author of unball cannot tell much beyond the fact that the only complete tool seems to be Windows-only.";;
+ "application/x-gzip"|"x-gzip") extract extract_gbzip gunzip "$FILE" "gzipped file";;
+ "application/x-iso9660-image") DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is an ISO9660 CD or DVD image. To access it's contents, mount it using a loopback device, or burn it to a disc.";;
+ "application/lzh"|"application/x-lzh"|"application/x-lha"|"application/x-lzh-archive"|"application/x-lharc"*) extract lha x "$FILE" "lzh archive";;
+ "application/x-lzop") extract lzop -x "$FILE" "lzop archive";;
+ "application/macbinary"|"application/x-macbinary") extract extract_sit "" "$FILE" "MacBinary-encoded file";;
+ "application/x-rar") extract unrar "x -y -p-" "$FILE" "rar archive";;
+ "application/x-rpm") extract extract_rpm "" "$FILE" "RPM Package";;
+ "application/x-shar"|"application/x-sh") [ `sizeInKiB "$FILE"` -ge 512 ] && DELAYEDMESSAGES="$DELAYEDMESSAGES\n$FILE is unusually large for a shell script. It is probably a self-extracting archive. For security reasons, it was not executed automatically.";;
+ "application/x-stuffit") extract extract_sit "" "$FILE" "Stuffit archive";;
+ "application/x-sv4cpio") extract cpio "--force-local --quiet -idI" "$FILE" "SV4 cpio archive";;
+ "application/x-tar"*|"application/x-gtar") extract tar xf "$FILE" "tar archive";;
+ "application/x-zip"|"application/zip") extract $UNZIPPER "$FILE" "zip archive";;
+ "application/x-zoo") extract zoo -extract "$FILE" "zoo archive";;
+ "application/octet-stream") echo "The file is a generic binary file. It may be an archive but unball cannot be sure.";;
+ "application/x-uuencode"|"x-uuencode") extract decode_uu "" "$FILE" "UUEncoded file";;
+ *) echo "File is not a known archive type." && SKIPPED=1;;
+ esac;;
+ esac
+ LASTERROR="$?"
+ elif [ -e "$FILE" ]; then
+ [ "$verbose" = 1 ] && echo "$FILE is not a regular file. Skipping."
+ else
+ echo "$FILE not found."
+ fi
+ return "$LASTERROR"
+}
+
+# ===== Start of Main Program =====
+# Prep the requisite variables
+CURRDIR=`pwd`
+OUTDIR="$CURRDIR" # This will be changed if --dir is used.
+
+# Jury-rig some flexibility
+exists unrar || (exists rar && alias unrar="rar")
+exists 7z || (exists 7za && alias 7z="7za")
+
+# Parse the options
+arg="$1"
+while [[ $arg = -* ]]; do
+ case "$1" in
+ -h|--help) show_help && exit 0;;
+ --version) show_version && exit 0;;
+ -v|--verbose) verbose=1 && shift;;
+ -d|--dir) OUTDIR="$2" && shift 2;;
+ -D|--samedir) samedir=1 && shift;;
+ --) shift && break;;
+ *) break;;
+ esac
+ arg="$1"
+done
+
+# Add support for sourcing this for it's functions
+if [ "$1" = "--source" ]; then
+ export abspath exists isprog lower pathjoin pathsplit sizeInKiB
+ return 0
+fi
+
+# If no arguments were provided, then show the help and exit.
+[ $# = 0 ] && show_help && exit 1
+
+# Check for things which could cause problems
+[ ! -w "$OUTDIR" ] && echo "FATAL: unball does not have write permissions for target directory" && exit 2
+
+# Parse the arguments and act on them
+LASTERROR=0
+for FILE in "$@"; do
+ extractify "$FILE" # Identify and extract.
+ TMP="$?" && [ "$TMP" != 0 ] && LASTERROR="$TMP"
+done
+
+#if isprog rar && [ \! "$I_AM_INCONSIDERATE" ]; then
+# echo "Please consider removing the \"rar\" command from your system. It's proprietary nature makes it difficult for people with esoteric hardware to extract rar archives and the unrar command can be installed separately from the rar command."
+#fi
+
+(([ -n "$DELAYEDMESSAGES" ] && echo -e "$DELAYEDMESSAGES") &&
+([ -n "$SKIPPED" ] && echo "Some of the given files were skipped because they were not archives or were in an unsupported format.")) ||
+exit "$LASTERROR"

0 comments on commit 53aeb02

Please sign in to comment.
Something went wrong with that request. Please try again.