diff --git a/.gitignore b/.gitignore index 0fc5d12..1ba43e5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ emacs/.emacs.d/.emacs.desktop.lock emacs/.emacs.d/tramp emacs/.emacs.d/projectile-bookmarks.eld emacs/.emacs.d/.python-environments +last +tmp +generation diff --git a/Makefile b/Makefile index 71f8faf..26b3eee 100644 --- a/Makefile +++ b/Makefile @@ -1,68 +1,63 @@ -DOTDEE=update-dotdee -STOW=xstow -PWD=$(shell pwd) -STOWOPTS=-f -target $(HOME) -d $(PWD) -DOTGITCONFIG=~/.gitconfig -DOTPROFILE=~/.profile - -.PHONY: mosh common emacs git ruby haskell perl tmux vim zsh list osx linux ws nix - -all: common - -common: $(DOTPROFILE) - -ws: emacs nix mosh git ruby haskell perl tmux vim zsh common - -$(DOTGITCONFIG): - $(STOW) $(STOWOPTS) git - touch $(DOTGITCONFIG) - $(DOTDEE) $(DOTGITCONFIG) - -clean: - $(STOW) $(STOWOPTS) -D mosh common emacs git ruby haskell perl tmux vim zsh osx - -rm $(DOTGITCONFIG) $(DOTPROFILE) - -rm -fr $(DOTCONFIG).d $(DOTPROFILE).d - -find $(PWD) -type f -name ".checksum" -exec rm {} \; - -$(DOTPROFILE): - $(STOW) $(STOWOPTS) common - touch $(DOTPROFILE) - $(DOTDEE) $(DOTPROFILE) - -git: $(DOTGITCONFIG) - +# Makefile is here to make it possible to use this whole shebang +# outside of emacs. +.PHONY: tangle tangle-next +DEST:=$(HOME) +LAST:=$(shell cat last || echo 0) +NEXT:=$(shell l=$(LAST); ((l=l+1)); echo $$l) +NEXTGEN:=$(PWD)/generation/$(NEXT) +LASTGEN:=$(PWD)/generation/$(LAST) +TANGLERS:=readme.org +GEN:=$(LAST) +OPTIONS:= + +all: clean tangle-next + +tmp: + install -dm755 $@ + $(MAKE) emacs + +#special target to handle emacs configuration emacs: - $(STOW) $(STOWOPTS) emacs # $@? + install -dm755 tmp/.emacs.d + install -m400 init.el tmp/emacs.d/init.el + install -m400 emacs.org tmp/emacs.d/emacs.org + +$(NEXTGEN): + install -dm755 $@ -osx: - $(STOW) $(STOWOPTS) osx +$(LASTGEN): + install -dm755 $@ -linux: - $(STOW) $(STOWOPTS) linux +generation/$(GEN): + install -dm755 $@ -x: - $(STOW) $(STOWOPTS) x +generation: $(NEXTGEN) $(LASTGEN) tmp + cd tmp && cp -av . $(NEXTGEN) -ruby: - $(STOW) $(STOWOPTS) ruby +check: -mosh: - $(STOW) $(STOWOPTS) mosh +diff: generation/$(GEN) + ./ddiff $(PWD)/generation/$(GEN) $(DEST) -zsh: - $(STOW) $(STOWOPTS) zsh +next: diff -tmux: - $(STOW) $(STOWOPTS) tmux +tangle-next: + $(MAKE) tangle + $(MAKE) generation + $(MAKE) next + $(MAKE) copy GEN=$(NEXT) + @echo $(NEXT) > last -vim: - $(STOW) $(STOWOPTS) vim +copy: + cd $(PWD)/generation/$(GEN) && find . -type f -exec rm -f $(DEST)/{} \; + cd $(PWD)/generation/$(GEN) && cp -r . $(DEST) -haskell: - $(STOW) $(STOWOPTS) haskell +tangle: tmp + /usr/bin/env emacs --script ./etangle $(TANGLERS) + @echo -perl: - $(STOW) $(STOWOPTS) perl +clean: + -rm -fr tmp -nix: - $(STOW) $(STOWOPTS) nix +nuke: clean + -rm -fr last generation diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 52c1ea1..0000000 --- a/Vagrantfile +++ /dev/null @@ -1,50 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -ENV['VAGRANT_DOTFILE_PATH'] = "/tmp/vagrant" -Vagrant.configure("2") do |config| - config.vm.define "ubuntu1204" do |ubuntu1204| - ubuntu1204.vm.box = "precise64" - ubuntu1204.vm.synced_folder ".", "/home/vagrant/dotfiles" - ubuntu1204.vm.provision "shell", - privileged: false, - inline: "if [ ! -e /var/tmp/.done ]; then -sudo apt-get clean -sudo rm -fr /var/lib/apt/lists -sudo apt-get update -# git 2.N+ instead of ass old git -sudo apt-get install -y -q python-software-properties -sudo add-apt-repository ppa:git-core/ppa -sudo apt-get update -sudo apt-get install -y -q xstow python-pip git pax zsh -sudo pip install update-dotdee -sudo usermod -s /bin/zsh vagrant -touch /var/tmp/.done -fi -cd ~/dotfiles -make clean && make -" - end - - # 10.{10,9} are the same basically - osx_cmd = "sudo xcodebuild -license accept -sudo xcode-select -s /Applications/Xcode.app -ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\" -export PATH=/usr/local/bin:${PATH} -brew install gcc xstow python -pip install update-dotdee -cd ~/dotfiles -make clean && make -" - config.vm.define "yosemite" do |yosemite| - yosemite.vm.box = "yosemite" - yosemite.vm.synced_folder ".", "/Users/vagrant/dotfiles" - yosemite.vm.provision "shell", privileged: false, inline: osx_cmd - end - - config.vm.define "mavericks" do |mavericks| - mavericks.vm.box = "mavericks" - mavericks.vm.synced_folder ".", "/Users/vagrant/dotfiles" - mavericks.vm.provision "shell", privileged: false, inline: osx_cmd - end -end diff --git a/common/.dir_colors b/common/.dir_colors deleted file mode 100644 index b17860e..0000000 --- a/common/.dir_colors +++ /dev/null @@ -1,100 +0,0 @@ -COLOR tty - -TERM ansi -TERM color-xterm -TERM con132x25 -TERM con132x30 -TERM con132x43 -TERM con132x60 -TERM con80x25 -TERM con80x28 -TERM con80x30 -TERM con80x43 -TERM con80x50 -TERM con80x60 -TERM cons25 -TERM console -TERM cygwin -TERM dtterm -TERM eterm-color -TERM Eterm -TERM gnome -TERM konsole -TERM kterm -TERM linux -TERM linux-c -TERM mach-color -TERM putty -TERM rxvt -TERM rxvt-cygwin -TERM rxvt-cygwin-native -TERM rxvt-unicode -TERM screen -TERM screen-bce -TERM screen-w -TERM screen.linux -TERM vt100 -TERM xterm -TERM xterm-256color -TERM xterm-color -TERM xterm-debian - -# Below are the color init strings for the basic file types. A color init -# string consists of one or more of the following numeric codes: -# Attribute codes: -# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed -# Text color codes: -# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white -# Background color codes: -# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white -NORMAL 00 # global default, although everything should be something. -FILE 00 # normal file -DIR 01;34 # directory -LINK 01;36 # symbolic link. (If you set this to 'target' instead of a - # numerical value, the color will match the file pointed to) -FIFO 40;33 # pipe -SOCK 01;35 # socket -DOOR 01;35 # door -BLK 40;33;01 # block device driver -CHR 40;33;01 # character device driver -ORPHAN 01;05;37;41 # orphaned syminks -MISSING 01;05;37;41 # ... and the files they point to - -# This is for files with execute permission: -EXEC 01;32 - -# List any file extensions like '.gz' or '.tar' that you would like ls -# to colorize below. Put the extension, a space, and the color init string. -# (and any comments you want to add after a '#') - -.cmd 01;32 # executables (bright green) -.exe 01;32 -.com 01;32 -.btm 01;32 -.bat 01;32 -.sh 01;32 -.csh 01;32 -.ksh 01;32 -.zsh 01;32 - -.tar 01;31 # archives / compressed (bright red) -.tgz 01;31 -.arj 01;31 -.taz 01;31 -.lzh 01;31 -.zip 01;31 -.z 01;31 -.Z 01;31 -.gz 01;31 -.bz2 01;31 -.bz 01;31 -.tbz2 01;31 -.tz 01;31 -.deb 01;31 -.rpm 01;31 -.rar 01;31 # app-arch/rar -.ace 01;31 # app-arch/unace -.zoo 01;31 # app-arch/zoo -.cpio 01;31 # app-arch/cpio -.7z 01;31 # app-arch/p7zip -.rz 01;31 # app-arch/rzip diff --git a/common/.hushlogin b/common/.hushlogin deleted file mode 100644 index e69de29..0000000 diff --git a/common/bin/cidr b/common/bin/cidr deleted file mode 100755 index 77e9e04..0000000 --- a/common/bin/cidr +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env perl -# -# Convert input ip/cidr|netmask|hexnetmask to useable network information. -# - -use strict; -use warnings; -use Socket; -use Sys::Hostname; - -# -# Globalish vars -# -$ENV{PATH} = '/usr/bin:/bin:/usr/sbin:/sbin'; # Paranoia, know thy name! -my ($fqdn_regexp) = qr/([0-9,a-z,A-Z,\-,\_]+)\.([0-9,a-z,A-Z,\-,\_]+)\.(com|gov)/; - -# -# converts a 1-word (4 byte) signed or unsigned integer into a dotted decimal -# ip address. -# -sub int2ip { - my $n=int(pop); - return(sprintf("%d.%d.%d.%d", ($n>>24)&0xff,($n>>16)&0xff, - ($n>>8)&0xff,$n&0xff)); -}; - -# -# Convert a host/ip/netmask/cidr/etc.... to a hash of information -# Example: host.domain.tld/24 will get the ip and calculate the netmask info -# equally if host.domain.tld corresponds with 1.2.3.4 the following is valid -# 1.2.3.4/255.255.255.0 would obtain the same information. -# -# die()'s if anything isn't kosher. -# -# Ultra long function, probably needs to be looked at for condensing/splitting. -# -sub cidr2raw { - my $rawinput = pop; - my ($lhs, $rhs, $j, $uip) = (undef, undef, undef, undef); - my ($ucidr) = 0; - my ($network, $bits, $netmask, $broadcast, $low, $high); - - if ($rawinput =~ qr/(.*)\/(.*)/){ - $lhs = $1; $rhs = $2; - }else{ - die "Input: $rawinput not expected.\n"; - }; - - # - # Handle ip/hostname for left hand side. - if ($lhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ - foreach my $dotted (($1,$2,$3,$4)){ - if (($dotted > 255) or ($dotted < 0)){ - die "FATAL: ipv4 address entered, $lhs entered is impossible, $dotted is not between 0-255.\n"; - }; - }; - $uip = inet_ntoa(scalar gethostbyname($lhs)); - die "FATAL: Cannot determine hostname for $lhs$!\n" if (!defined($lhs)); - }elsif ($lhs =~ $fqdn_regexp){ - my $tmp = gethostbyname($lhs); - die "FATAL: Cannot determine ip for $lhs" if (!defined($tmp)); - $uip = inet_ntoa($tmp); - }else{ - die "FATAL: host value not fully qualified, or not an ip <$lhs>\n"; - }; - - # - # Handle the netmask/cidr for the right hand side, - # - # All input netmasks are converted to a cidr address for notation - if ($rhs =~ qr/^(\d+)$/){ # /cidr - $ucidr = $1; - die "FATAL: Invalid CIDR <$ucidr>.$!\n" if (($ucidr > 32) or ($ucidr < 0)); - }elsif ($rhs =~ qr/(0[xX])?([0-9,a-f,A-F]{7})/){ # /0xhexnetmask - my $trimmed = $2; - my $insane = 0; - foreach my $byte (split('', unpack("B32", pack("H*", $trimmed)))){ - ($byte) ? $ucidr++ : $insane++; - die "FATAL: $rhs is not a valid hex netmask.$!\n" if ($insane and $byte); - }; - }elsif ($rhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ # /255.255.255.0 form - my @a = ($1, $2, $3, $4); - my $insane = 0; - foreach my $t (@a){ - die "FATAL: Netmask out of range. Input <$rhs> Invalid <$t>$!\n" if (($t < 0) or ($t > 255)); - }; - foreach my $byte (split('', unpack("B32", pack("C4", @a)))){ - ($byte) ? $ucidr++ : $insane++; - die "FATAL: $rhs is not a valid netmask.$!\n" if ($insane and $byte); - }; - }else{ - die "FATAL: Unknown or invalid netmask value entered. <$rhs>\n"; - }; - - # - # Network math GO! This is the meat of the function. - my (@uip) = split(/\./, $uip); - $network = 0; - for ($j = 0; $j <= $#uip; $j++){ - $network += int($uip[$j])<<((3-$j)*8); - }; - - $bits = 0; $j = 0; - for ($j = 31 - $ucidr; $j >= 0; $j--){ - $bits |= 1<<$j; - }; - - $netmask = 0xffffffff^$bits; - $low = ($network&$netmask); - $high = ($network&$netmask)+$bits-1; - $broadcast = ($network&$netmask)|$bits; - my ($guessed_hostname,undef,undef,undef,undef) = gethostbyaddr(inet_aton($uip), AF_INET); - - # - # Throw the info back, they get a hash with zie info they may/may not need. - # All up to the caller what they want to use. - # - return ("inet4" => $uip, - "netmask" => int2ip($netmask), - "broadcast" => int2ip($broadcast), - "cidr" => $ucidr, - "router" => int2ip($low+1), - "network" => int2ip($low), - "high" => int2ip($high), - "hostname" => $guessed_hostname, - ); -}; - -#package Main; # future use - -foreach my $arg (@ARGV){ - my %stuff = cidr2raw($arg); - printf("%s/%s is %s/%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n", - $stuff{"inet4"},$stuff{"cidr"}, - $stuff{"network"},$stuff{"cidr"}, - "Netmask",$stuff{"netmask"}, - "Broadcast",$stuff{"broadcast"}, - "Network",$stuff{"network"}, - "Router",$stuff{"router"}, - "HighUsable",$stuff{"high"}, - ); -}; diff --git a/common/bin/diskhog b/common/bin/diskhog deleted file mode 100755 index 0c8c6de..0000000 --- a/common/bin/diskhog +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env perl -# -# Find out who is hogging disk space and where. -# -# Argument is the directory to start from. Only calculates size of files. -# Adds the size of files in a directory to the size of the parent directory only. -# -# Defaults to top 10 directories/files. -# -# Override with -n num to list whatever amount of large things you desire. -# Or if you want to abuse the parser, use -1 for all files/directories. -# -# Defaults to pwd for space. -# - -use File::Find; -use Getopt::Long; -use Cwd; - -my $debug; -my $statbug; -(exists($ENV{"DEBUG"})) ? $debug++ : undef; -my $dir = Cwd::abs_path($ARGV[-1] || Cwd::getcwd()); -my %diskhogs = (); -my %inodes = (); -my ($topdev,undef,undef,undef,undef,undef,undef,undef) = lstat($dir); -local $opt_displaynum = 10; - -GetOptions( 'n=i', => \$opt_displaynum, - ); - -find(\&sieve, $dir); - -# -# For outputing the size of a bunch of bytes in g/m/k depending upon the size -# -sub byte_print { - my $byte_k = 1_024; - my $byte_m = $byte_k**2; - my $byte_g = $byte_k**3; - my $bytes = pop; - my $base = $bytes; - my $suffix = "nil"; - my $out_string = "BUG"; - if($bytes > $byte_g){ - $base = $bytes / $byte_g; - $suffix = "g"; - }elsif($bytes > $byte_m){ - $base = $bytes / $byte_m; - $suffix = "m"; - }else{ - $base = $bytes / $byte_k; - $suffix = "k"; - }; - $out_string = sprintf("%.2f%s", $base, $suffix); - return $out_string; -}; - -# -# Dumb function to return if an inode has already been seen. -# So we handle hard links sane(er-ish-ly) in size calculations. -# This has more truthiness(tm). -# -sub seeninode{ - my $what = pop(); - my $ret = 0; - unless(exists($inodes{$what})){ - $inodes{$what} = 0; - print "New inode $what added to seen inodes.\n" if $debug; - }else{ - $inodes{$what}++; - $ret++; - print "Found a hardlink for $what.\n" if $debug; - }; - return $ret; -}; - -sub sieve { - my $file = $File::Find::name; - my $filedir = $File::Find::dir; - my @statinfo = lstat($file); - my $dev = $statinfo[0]; - my $inode = $statinfo[1]; - my $size = $statinfo[7]; - my $blocksize = 512; # field 11 is the "preferred" block size, which appears - # to not match the actual blocksize of the filesystems - # in use. For now every hard drive uses 512bytes/block. - # Will revisit this when 4096byte/block hard drives arrive - my $apparentsize = $statinfo[12] * $blocksize; - - print "$file\@$filedir \<$topdev\>\=\<$dev\>\n" if $debug; - print "size,apparentsize,blocksize = <$statinfo[7],$apparentsize\,$blocksize\>\n" if $debug; - # - # Try to handle sparse files. - # - if ($size > $apparentsize) { - print "Sparse file $file!\n" if $debug; - $size = $apparentsize; - }; - - $dev = (-l $file) ? 0xdeadbeef : $dev; - if (($file =~ m/\/proc|\/chroot|udev\/devices/) || - ($dev != $topdev) || seeninode($inode)){ - print "Pruned $file.\n" if $debug; - $File::Find::prune = 1; - next; - }; - unless ($dev){ - # Yay, we can't l(stat) files. This version of perl is broken. - # Snag information from ls, assume it's a file. Thanks Solaris 8, you suck. - $statbug++; - warn "Hit empty device statbug while stat()ing file <$file>.\n"; - my $ls = qx(ls -ld $file); - my @raw = split(/\s+/, $ls); - $diskhogs{"$file"} = $raw[4]; - $diskhogs{"$filedir"} += $raw[4]; - }elsif (-f){ - if ($debug){ - print "Adding $file size ", &byte_print($size), " to $filedir.\n"; - print "Adding $file size ", &byte_print($size), "\n"; - }; - $diskhogs{"$file"} = $size; - $diskhogs{"$filedir"} += $size; - }elsif (-d){ - print "Adding $file size ".&byte_print($size)."\n" if $debug; - $diskhogs{"$file"} += $size; - }; - if ($debug) { - print "$file from $filedir has size ".&byte_print($diskhogs{"$file"})."\n"; - }; -}; - -# -# Reverse sort the keys by size. -# -my @sorted = sort {$diskhogs{$b} <=> $diskhogs{$a}} keys %diskhogs; - -splice @sorted, $opt_displaynum if @sorted > $opt_displaynum; - -warn "Found one or more instances of the stat() call statbug. This is normally only present on Solaris 8 with stock perl.\n" if $statbug; - -foreach (@sorted){ - printf "%-9s%s\n", &byte_print($diskhogs{$_}), $_; -}; - -if ($debug){ - print "DEBUG INFORMATION:\n"; - foreach (keys %diskhogs){ - printf "%-9s%s\n", &byte_print($diskhogs{$_}), $_; - }; -}; diff --git a/common/bin/dns b/common/bin/dns deleted file mode 100755 index a04484e..0000000 --- a/common/bin/dns +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env perl -# -# Stupid script to help with dns information. Solaris 9/8 lack the host utility. -# Which this (kinda) mimics, except the mx record crap -use strict; -use warnings; -use Socket; -use Sys::Hostname; - -my $input = shift || hostname(); -my $lookup = $input; - -if ( $lookup =~ /\d+[.]\d+[.]\d+[.]\d+/smx ) { - $lookup = ( gethostbyaddr inet_aton($lookup), AF_INET )[0]; - die "Error: Unable to reverse lookup ip $input.\n" if ( $lookup eq q{} ); -} - -my $ipv4 = gethostbyname $lookup; - -die "Error: $lookup doesn't have any known ip addresses\n" - if ( !defined $ipv4 ); - -$ipv4 = inet_ntoa($ipv4); - -my ( $short_name, $aliases, $addrtype, $len, @addrs ) = gethostbyname $lookup; - -foreach my $ipv4 (@addrs) { - $ipv4 = inet_ntoa($ipv4); - print "$lookup is $ipv4\n"; -} - -print "$lookup is also $short_name\n"; -if ( defined $aliases and "$aliases" ne q{} ) { - print "aliases are ($aliases)\n"; -} -exit 0; diff --git a/common/bin/dups b/common/bin/dups deleted file mode 100755 index aa56109..0000000 --- a/common/bin/dups +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env ruby -# -# Quick script to find duplicate files -# - -require 'find' -require 'digest/sha1' -require 'set' - -hashes = Hash.new -start = ARGV[0] || ENV["HOME"] -puts "Building digests from #{start}" - -Find.find(start) do |path| - STDOUT.flush - this_hash = Set.new - hash = "NONE" - if (FileTest.directory?(path) or FileTest.symlink?(path)\ - or FileTest.blockdev?(path) or FileTest.chardev?(path)\ - or FileTest.socket?(path) or FileTest.pipe?(path)\ - or FileTest.zero?(path)) then - next - else - begin - file_digest = Digest::SHA1.new - File.open(path, 'r') do |fh| - while buffer = fh.read(8096) - file_digest.update(buffer) - end - end - hash = file_digest.hexdigest - rescue NoMemoryError - puts "NoMemoryError on #{path}" - GC.start - rescue IOError - puts "IOError on #{path}" - GC.start - rescue Errno::ENOSYS; next - rescue Errno::EACCES; next - rescue Errno::EINVAL; next - rescue => e - puts "Unhandled error on #{path}, exception #{e}" - p e - exit 255 - end - end - if (hashes[hash]) then - hashes[hash].add(path) - else - hashes[hash] = this_hash.add(path) - end -end - -puts "Digest generation complete." -hashes.each_pair do |key, val| - files = val.to_a - files.delete(nil) - files.delete_if {|x| "#{x}" =~ /^\s*$/} - next if (files.size < 2) - puts "Duplicate digest <#{key}> for files:\n #{files.join("\n ")}" -end diff --git a/common/bin/emptydirs b/common/bin/emptydirs deleted file mode 100755 index 1822fe7..0000000 --- a/common/bin/emptydirs +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env perl -# -# Because all find implementations, that is, everything but gnu find. -# lack -find as an option. -# - -use File::Find; - -my $debug; -(exists($ENV{"DEBUG"})) ? $debug++ : undef; -my $dir = $ARGV[-1] || '/tmp'; - - -find(\&sieve, $dir); - -sub sieve { - my $file = $File::Find::name; - my $filedir = $File::Find::dir; - my ($dev,$inode,undef,undef,undef,undef,undef,$size) = lstat($file); - next if !(-d $file); # Only zie diectories BITTE! - # - # Ok, lets see if readdir returns more than 2 entries. - opendir my $H, $file or next; - print "$file\n" unless (grep !/^\.{1,2}/, readdir $H); - close $H; -}; diff --git a/common/bin/gecos b/common/bin/gecos deleted file mode 100755 index ac082d0..0000000 --- a/common/bin/gecos +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env perl -# -# Dumb wrapper to get the gecos information from a uid/username. - -foreach my $input (@ARGV){ - my $gecos = undef; - my $uid = undef; - my $name = undef; - if ( $input =~ m/^\d+$/ ) { - ( $name,$uid,$gecos ) = ( getpwuid($input) )[0,2,6]; - } else { - ( $name,$uid,$gecos ) = ( getpwnam($input) )[0,2,6]; - } - print "$name is '$gecos' uid '$uid'\n" if $gecos; -} diff --git a/common/bin/hatimerun b/common/bin/hatimerun deleted file mode 100755 index 2eaa079..0000000 --- a/common/bin/hatimerun +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env perl -# -# hatimerun in perl, sorta -# -use Getopt::Long; - -my $opt_exitcode = 99; -my $opt_killcode = 9; -my $opt_timeout = 60; - -GetOptions( 'e=i' => \$opt_exitcode, - 'k=i' => \$opt_killcode, - 't=i' => \$opt_timeout, - 'h' => \&opt_help, - 'help' => \&opt_help, -); - -sub opt_help{ - my $message = <<__END__; -UX: ERROR: invalid syntax -usage: [-e return code][-k kill signal][-t seconds to wait] - [-h][--help] - - Options - --help, -h Prints this help text. - -e Exit code to return on timeout. - NOTE: 99 by default. - -k Signal number to send via kill. - NOTE: 9 by default. - -t Timeout in seconds before alarming. - NOTE: 60 by default. - -__END__ - print $message; - exit 1; -}; - -my $pid; - -local $SIG{ALRM} = sub { kill $opt_killcode, $pid or die "Kill failed: $!"; - die "Timeout!\n"}; - -eval{ - my $x = defined($pid = fork()); - - unless ($pid){ - print qx(@ARGV); - die "Exec of ", join(' ', @ARGV), " failed at $!\n"; - }; - - alarm $opt_timeout; - waitpid $pid => 0; - alarm 0; - exit 0; -}; - -if ($@){ - die "Nothing to do!\n" unless $@ eq "Timeout!\n"; - exit $opt_exitcode; -}else{ - exit 0; -}; diff --git a/common/bin/ifinfo b/common/bin/ifinfo deleted file mode 100755 index 02bc0d6..0000000 --- a/common/bin/ifinfo +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env perl -# -# Because ifconfig output is... overly verbose. -# -# Output information from ifconfig -a like so: -# interface:mtu ipv4/cidr mac_address ipv6_addr(if applicable) -# ipv6 is not yet in place due to a: lazy, b: can't use it yet. -# - -use strict; -use Socket; -use Sys::Hostname; -$ENV{'PATH'}='/sbin:/usr/sbin:/bin:/usr/bin'; - -my ($fqdn_regexp) = qr/([0-9,a-z,A-Z,\-,\_]+)\.([0-9,a-z,A-Z,\-,\_]+)\.(com|gov)/; - -# -# converts a 1-word (4 byte) signed or unsigned integer into a dotted decimal -# ip address. -# -sub int2ip { - my $n=int(pop); - return(sprintf("%d.%d.%d.%d", ($n>>24)&0xff,($n>>16)&0xff, - ($n>>8)&0xff,$n&0xff)); -}; - -# -# Convert a host/ip/netmask/cidr/etc.... to a hash of information -# Example: host.domain.tld/24 will get the ip and calculate the netmask info -# equally if host.domain.tld corresponds with 1.2.3.4 the following is valid -# 1.2.3.4/255.255.255.0 would obtain the same information. -# -# die()'s if anything isn't kosher. -# -# Ultra long function, probably needs to be looked at for condensing/splitting. -# -sub cidr2raw { - my $rawinput = pop; - my ($lhs, $rhs, $j, $uip) = (undef, undef, undef, undef); - my ($ucidr) = 0; - my ($network, $bits, $netmask, $broadcast, $low, $high); - - if ($rawinput =~ qr/(.*)\/(.*)/){ - $lhs = $1; $rhs = $2; - }else{ - die "Input: $rawinput not expected.\n"; - }; - - # - # Handle ip/hostname for left hand side. - if ($lhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ - foreach my $dotted (($1,$2,$3,$4)){ - if (($dotted > 255) or ($dotted < 0)){ - die "FATAL: ipv4 address entered, $lhs entered is impossible, $dotted is not between 0-255.\n"; - }; - }; - $uip = "$1.$2.$3.$4"; - }; - # - # Handle the netmask/cidr for the right hand side, - # - # All input netmasks are converted to a cidr address for notation - if ($rhs =~ qr/^(\d+)$/){ # /cidr - $ucidr = $1; - die "FATAL: Invalid CIDR <$ucidr>.$!\n" if (($ucidr > 32) or ($ucidr < 0)); - }elsif ($rhs =~ qr/(0[xX])?([0-9,a-f,A-F]{7})/){ # /0xhexnetmask - my $trimmed = $2; - my $insane = 0; - foreach my $byte (split('', unpack("B32", pack("H*", $trimmed)))){ - ($byte) ? $ucidr++ : $insane++; - die "FATAL: $rhs is not a valid hex netmask.$!\n" if ($insane and $byte); - }; - }elsif ($rhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ # /255.255.255.0 form - my @a = ($1, $2, $3, $4); - my $insane = 0; - foreach my $t (@a){ - die "FATAL: Netmask out of range. Input <$rhs> Invalid <$t>$!\n" if (($t < 0) or ($t > 255)); - }; - foreach my $byte (split('', unpack("B32", pack("C4", @a)))){ - ($byte) ? $ucidr++ : $insane++; - die "FATAL: $rhs is not a valid netmask.$!\n" if ($insane and $byte); - }; - }else{ - die "FATAL: Unknown or invalid netmask value entered. <$rhs>\n"; - }; - - # - # Network math GO! This is the meat of the function. - my (@uip) = split(/\./, $uip); - $network = 0; - for ($j = 0; $j <= $#uip; $j++){ - $network += int($uip[$j])<<((3-$j)*8); - }; - - $bits = 0; $j = 0; - for ($j = 31 - $ucidr; $j >= 0; $j--){ - $bits |= 1<<$j; - }; - - $netmask = 0xffffffff^$bits; - $low = ($network&$netmask); - $high = ($network&$netmask)+$bits-1; - $broadcast = ($network&$netmask)|$bits; - - # - # Throw the info back, they get a hash with zie info they may/may not need. - # All up to the caller what they want to use. - # - return ("inet4" => $uip, - "netmask" => int2ip($netmask), - "broadcast" => int2ip($broadcast), - "cidr" => $ucidr, - "router" => int2ip($low+1), - "network" => int2ip($low), - "high" => int2ip($high), - ); -}; - -my @ifout; -if ($ENV{'TESTING'} ne '') { - while(<>){ - chomp($_); - last if ($_ eq ''); - push(@ifout, $_); -# sleep 1; -# print STDERR $_ . "\n"; - } -}else{ - open IFCONFIG, "ifconfig -a |"; - @ifout = ; - close IFCONFIG; -} - -# This seems wrong but it makes parsing easier due to solaris -# non root ifconfig not displaying the mac address. Reverse the output. -# -@ifout = reverse(@ifout); - -my @output = (); - -my ($ifname, $ifether, $ifmtu, $ifipv4, $ifnetmask, $ifipv6) = (undef,undef,undef,undef,undef,undef); -sub printiface{ - # assume a /32 if we don't know it - unless (defined($ifnetmask)) { - warn "$ifname has indeterminant netmask assuming /32\n"; - $ifnetmask = '32'; - } - - unless (defined($ifnetmask)) { - $ifether = 'unknown'; - } - - unless ($ifname =~ m/lo.*/){ - my %netinfo = cidr2raw("$ifipv4\/$ifnetmask"); - $ifnetmask = $netinfo{"cidr"}; - $ifether = lc($ifether); - my $line = sprintf "%-16s %-18s %-17s\n", "$ifname\@$ifmtu", "$ifipv4\/$ifnetmask", $ifether; - push @output, $line; - } - - # reset vars - ($ifname, $ifether, $ifmtu, $ifipv4, $ifnetmask, $ifipv6) = (undef,undef,undef,undef,undef,undef); -}; - -foreach my $line (@ifout) { - if ($line =~ /inet\s+(\d+[.]\d+[.]\d+[.]\d+)\s+/){ - $ifipv4 = $1; - } - if ($line =~ m/ether\s([:,0-9,a-f,A-F]{11,})/){ - $ifether =$1; - } - if ($line =~ m/^([\w,\:\d+]+)\s+.*HWaddr\s([:,0-9,a-f,A-F]{11,})/){ - $ifname = $1; - $ifether = $2; - } - if ($line =~ m/^(.*)\:\s+.*mtu\s(\d+)/){ - $ifname = $1; - $ifmtu = $2; - } - if ($line =~ m/MTU[:](\d+)/){ - $ifmtu = $1; - } - if ($line =~ m/inet\saddr\:(\d+[.]\d+[.]\d+[.]\d+)/){ - $ifipv4 = $1; - } - if ($line =~ m/netmask\s+(0[xX])?([a-f,A-F,0-9]{8})/){ - $ifnetmask = $2; - } - if ($line =~ m/Mask[:](\d+\.\d+\.\d+\.\d+)/){ - $ifnetmask = $1; - } - if ($line =~ m/netmask\s+(\d+[.]\d+[.]\d+[.]\d+)/){ - $ifnetmask = $1; - } - if ($line =~ m/netmask\s+0\s+broadcast/){ - $ifnetmask = '0'; - } - - print ":$ifether:$ifname:$ifmtu:$ifipv4:$ifnetmask:$ifipv6:\n" if ($ENV{'DEBUG'} ne ''); - printiface() if ($ifname and $ifmtu and $ifipv4 ); -}; - -if (scalar(@output) < 1){ - warn "No interfaces? Scripts busted yo.\n"; -}else{ - foreach my $line (reverse(@output)){ - print $line; - } -} diff --git a/common/bin/iso8601 b/common/bin/iso8601 deleted file mode 100755 index faf5e89..0000000 --- a/common/bin/iso8601 +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env perl -#-*-mode: Perl; coding: utf-8;-*- -use strict; -use warnings; -use POSIX qw(strftime); - -my $now = time; -my $tz = strftime(('%z', (localtime $now))); -$tz =~ s/(\d{2})(\d{2})/$1:$2/smx; -my $time = strftime('%Y-%m-%dT%H:%M:%S', (localtime $now)); -print "$time$tz\n"; -exit 0; diff --git a/common/bin/notify b/common/bin/notify deleted file mode 100755 index eb88bcf..0000000 --- a/common/bin/notify +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -message=${1:="no message"} -title='' -if [ "${2}" != "" ]; then - message="${2}" - title="${1}" -fi -notification="display notification \"${message}\"" -[ "${title}" != "" ] && notification="${notification} with title \"${title}\"" - -osascript -e "${notification}" diff --git a/common/bin/portchk b/common/bin/portchk deleted file mode 100755 index d4eeb5b..0000000 --- a/common/bin/portchk +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env perl -# -# Just opens a socket and tries to connect() to it. rc = 1 on failure, 0 success -# -use Socket; - -local $where = $ARGV[0]; -local $port = $ARGV[1]; - -socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname("tcp"))[2]); - -if(connect(SOCKET,sockaddr_in($port,inet_aton($where)))){ - print "connect($where, $port) succeeded\n"; - exit 0; -}else{ - print "connect($where, $port) failed\n"; - exit 1; -}; diff --git a/common/bin/ptree.pl b/common/bin/ptree.pl deleted file mode 100755 index d02733d..0000000 --- a/common/bin/ptree.pl +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env perl -# -# ptree for linux/darwin/solaris. I got sick of ps and pstree on linux. -# ptree works on solaris fine, but doesn't exist for darwin/linux/etc... -# -# TODO: Allow passing a regexp instead of a pid and passing multiple pids. -# - -local $ENV{"PATH"} = '/bin:/usr/bin:/sbin:/usr/sbin'; -local $debug = 0; - -(exists($ENV{"DEBUG"})) ? $debug = 1 : undef; -($debug) ? local $| = 1 : undef; # disable buffering for STDERR and STDOUT - -sub debug_print { - ($debug) && warn pop; -}; - -local @cmd = ('/bin/ps'); -local $init = 0; -local $start = 1; - -if ($^O eq "linux"){ - push(@cmd, 'ajxSw'); - $start = 0; -}elsif ($^O =~ m/darwin|freebsd/){ - push(@cmd, 'Ajwww'); -}elsif ($^O eq "solaris"){ - @cmd = ('/usr/ucb/ps'); - if ((-x "/bin/zonename") && !(qx(zonename) eq "global\n")){ - $init = qx(pgrep zsched); - chomp($init); - $start = $init; - }; - push(@cmd, 'laxwww'); -}else{ - die "$^O isn't a known os to this script\n"; -}; - -local @ps = qx(@cmd); -($?) ? die $cmd[0]." posix return code $?\n" : undef; - -local %proc; -local @trail; - -(defined($ARGV[0])) ? $start = $ARGV[0] : undef; - -debug_print("Dump of raw line array data:\n"); - -foreach my $x (@ps){ - my $cmd_index = 9; - my $ppid = -1; - my $pid = -1; - next if ($x =~ m/.*PID.*/); - my @line = split(m/\s+/,$x); - splice(@line, 0, 1) unless ($line[0] =~ m/\d+/); - splice(@line, 0, 1) if ("$line[0]" eq ""); - - if ($^O eq "linux"){ - ($ppid,$pid) = @line; - $cmd_index = 9; - }elsif ($^O =~ m/darwin|freebsd/){ - ($pid,$ppid) = @line; - $cmd_index = 8; - }elsif ($^O eq "solaris"){ - (undef, undef, $pid,$ppid) = @line; - for($x=$cmd_index; $x < 14; $x++){ - $cmd_index = ($line[$x] =~ m/\d+\:\d+/) ? ($x + 1) : $cmd_index; - }; - }; - - my $command = join(' ', @line[$cmd_index..$#line++]); - (!defined $proc{$pid}) ? $proc{$pid}->{"children"} = [ ] : undef; - (!defined $proc{$ppid}) ? $proc{$ppid}->{"children"} = [ ] : undef; - $proc{$pid}->{"pid"} = $pid; - $proc{$pid}->{"command"} = $command; - $proc{$pid}->{"ppid"} = $ppid; - push(@{$proc{$ppid}->{"children"}},$pid); - debug_print(join(',', @line[0..($#line-1)])."\n"); -}; - -if ($debug){ - debug_print("Done reading ps output\nDump of Hash\n"); - foreach my $key (sort({$a <=> $b} (keys %proc))){ - $ppid = $proc{$key}->{"ppid"}; - $command = $proc{$key}->{"command"}; - $children = join(',', @{$proc{$key}->{"children"}}); - debug_print("PID<$key> PPID<$ppid> Children<$children> Command<$command>\n"); - }; -}; - -sub intrail{ - my $crumb = pop; - my $ret = 0; - map {$ret++ if ($crumb == $_)} @trail; - return $ret; -}; - -sub addchildren{ - my $start_node = pop; - foreach my $child (@{$proc{$start_node}->{"children"}}){ - next if (!defined($child) || ($start_node == $child)); - debug_print("Start ($start_node) Add child $child.\n"); - push(@trail, $child); - addchildren($child); - }; -}; - -sub addparents{ - my $start_node = pop; - my $parent = $proc{$start_node}->{"ppid"}; - return unless (defined($start_node)); - return if (($parent == $start_node) || !(defined($parent))); # At the top of the tree, or in a zone - debug_print("Start ($start_node) Add parent $parent.\n"); - push(@trail, $parent); - addparents($parent) if ($parent != $init); -}; - -sub printnode{ - my $start_node = pop; - my $indent = pop; - if (intrail($start_node)){ - my $pid = $proc{$start_node}->{"pid"}; - my $ppid = $proc{$start_node}->{"ppid"}; - my $cmdline = $proc{$start_node}->{"command"}; - my $indentation = ' 'x($indent); - if ($pid == $init){ - my $s = $^O." kernel"; - if ($cmdline ne ''){ - $s = $s." <$cmdline>"; - }; - $cmdline = $s; - }; - printf("%s%d %s\n", $indentation, $pid, $cmdline); - foreach my $child (@{$proc{$start_node}->{"children"}}){ - next if ($pid == $child); - printnode($indent+1,$child); - }; - }; -}; - -my $valid = 0; -foreach my $j (keys %proc){ ($j == $start) ? $valid++ : undef; }; - -debug_print("Starting from <$start>, validity is<$valid>\n"); - -if ($valid){ - if (!$start){ - @trail = keys %proc; - push(@trail, $start); push(@trail, 1); - debug_print("Done with adding $start to trail.\n"); - }else{ - push(@trail, $start); - debug_print("Adding children from $start.\n"); - addchildren($start); - debug_print("Adding parents from $start.\n"); - addparents($start); - }; - - @trail = sort(@trail); - - debug_print("Trail is: ".join(',', @trail)."\nStarting at pid $start\ninit pid $init\n"); - print "PID COMMAND\n"; - my $startindent = 0; - (intrail($startindent)) ? $startindent = -1 : undef; - printnode($startindent,$init); -}else{ - die "pid $start doesn't exist.\n"; -}; - -exit 0; diff --git a/common/bin/today b/common/bin/today deleted file mode 100755 index e2e9636..0000000 --- a/common/bin/today +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env ruby -# - -cal, today, week_color, day_color, reset = %x(cal).split(%r(\n)), Time.now.day, %x(tput sgr0;tput setab 4;tput setaf 7), %x(tput sgr0; tput setab 0;tput setaf 7;tput bold), %x(tput sgr0) -done=false -cal.each do |line| - if done then - puts line - next - end - if(line =~ /^(.*\s+?)#{today}(\s+?.*)$/ or - line =~ /^(.*\s+?)#{today}$/ or - line =~ /^()#{today}(\s+?.*)$/ or - line =~ /^#{today}$/ ) then - puts "#{week_color}#{$1}#{day_color}#{today}#{week_color}#{$2}#{reset}" - done=true - else - puts line - end -end diff --git a/common/bin/ts b/common/bin/ts deleted file mode 100755 index a981e37..0000000 --- a/common/bin/ts +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env perl -# -# Timestamp stdin and then print to stdout and flush. -# -# Thats about it. Might add a quick and dirty option to allow you to -# specify the time output whatnot. But this is intended to be simple. -use strict; -use warnings; -use POSIX qw(strftime); -use IO::Handle; -STDOUT->autoflush(1); - -while(){ - my $now = time; - my $tz = strftime(('%z', (localtime $now))); - $tz =~ s/(\d{2})(\d{2})/$1:$2/smx; - my $time = strftime('%Y-%m-%dT%H:%M:%S', (localtime $now)); - print "$time$tz : ".$_; -}; diff --git a/common/bin/whoson b/common/bin/whoson deleted file mode 100755 index 89ea1f5..0000000 --- a/common/bin/whoson +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env perl -# -# Because i'm lazy and sick of typing in getent passwd $someusername/uid -# - -my %who_cmds = ("solaris", "/bin/who -q", - "linux", "/usr/bin/who -q", - "darwin", "/usr/bin/who -q", - ); - -my $who_cmd = $who_cmds{$^O}; - -local %users = (); - -foreach my $l (qx/$who_cmd/){ - next if($l =~ m/^\#.*/); - foreach my $user (split(/\s+/,$l)){ - unless(exists($users{$user})){ - $users{$user} = 0; - }else{ - $users{$user}++; - }; - }; -}; - -foreach my $user (keys %users){ - my $gecos = ( getpwnam($user) )[6]; - my $count = $users{$user} + 1; - my $output = "$user\, ".((defined($gecos)) ? "$gecos, " : '')."is logged in on $count tty".(($count>1) ? "\'s" : '')."\n"; - print $output; -}; diff --git a/ddiff b/ddiff new file mode 100755 index 0000000..a449952 --- /dev/null +++ b/ddiff @@ -0,0 +1,25 @@ +#!/usr/bin/env sh +#-*-mode: Shell-script; coding: utf-8;-*- +# File: ddiff.sh +# Copyright: 2016 Mitch Tishmack +# Description: Stupid recursive directory diff +export script=$(basename "$0") +export dir=$(cd "$(dirname "$0")"; pwd) +export iam=${dir}/${script} +rc=0 +src="$1" +dest="$2" + +cd "$src" || exit 1 +for file in $(find . -type f -print); do + ffile=$(echo "$file" | sed -e 's|\.\/||') + dfile=$(echo "${dest}/${file}" | sed -e 's|\.\/||') + if [ -e "${dfile}" ]; then + diff -u "${ffile}" "${dfile}" + rc=$((rc + $?)) + else + echo "source file ${ffile} not found in ${dest} as ${dfile}, ignoring" + fi +done + +exit $rc diff --git a/etangle b/etangle new file mode 100755 index 0000000..91ff656 --- /dev/null +++ b/etangle @@ -0,0 +1,16 @@ +;; Tangle an org mode file with babel using emacs. +(let ((default-directory "~/.emacs.d")) + (normal-top-level-add-subdirs-to-load-path)) + +(load-file (if (getenv "OPTIONS") + (concat (concat "./" (getenv "OPTIONS")) ".el") + "./options.el")) + +(require 'org-install) +(require 'org) + +;; Iterate through all the files given and tangle them +(dolist + (file command-line-args-left) + (princ file) + (org-babel-tangle-file file)) diff --git a/git/.gitconfig.d/00-user b/git/.gitconfig.d/00-user deleted file mode 100644 index 6c8d8b3..0000000 --- a/git/.gitconfig.d/00-user +++ /dev/null @@ -1,3 +0,0 @@ -[user] - email = mitch.tishmack@gmail.com - name = Mitch Tishmack diff --git a/git/.gitconfig.d/10-core b/git/.gitconfig.d/10-core deleted file mode 100644 index 8c4da9b..0000000 --- a/git/.gitconfig.d/10-core +++ /dev/null @@ -1,24 +0,0 @@ -[alias] - up = !sh -c 'git pull --rebase && git push' - wsdiff = diff --color-words --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-all-space - wdiff = diff --color-words - ci = commit - ciu = commit --all - co = checkout - ds = diff --stat - ba = branch --all - st = status --short --branch - unstage = reset HEAD - tlog = log --graph --color=always --abbrev-commit --date=relative --pretty=oneline - hist = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative - slog = log --oneline --decorate - fixup = commit --fixup - squash = commit --squash - ri = rebase --interactive --autosquash - ra = rebase --abort - effit = reset --hard - # What commits differ beteen branches, note, equivalent commits are omitted. - # Use this with three dot operator aka master...origin/master - cdiff = log --left-right --graph --cherry-pick --oneline - # Same as ^ only equivalent commits are listed with a = sign. - cmdiff = log --left-right --graph --cherry-pick --oneline diff --git a/git/.gitconfig.d/20-color-setup b/git/.gitconfig.d/20-color-setup deleted file mode 100644 index 07db50b..0000000 --- a/git/.gitconfig.d/20-color-setup +++ /dev/null @@ -1,19 +0,0 @@ -[pager] - color = true -[color] - status = auto - diff = auto - branch = auto -[color "status"] - added = green - changed = blue - untracked = red -[color "branch"] - current = green - local = blue - remote = red -[color "diff"] - meta = blue bold - frag = black reverse - old = red reverse - new = green reverse diff --git a/git/.gitconfig.d/30-gui-stuff b/git/.gitconfig.d/30-gui-stuff deleted file mode 100644 index 2867c06..0000000 --- a/git/.gitconfig.d/30-gui-stuff +++ /dev/null @@ -1,5 +0,0 @@ -[advice] - statushints = false -[gui] - fontui = -family Monaco -size 8 -weight normal -slant roman -underline 0 -overstrike 0 - fontdiff = -family Monaco -size 8 -weight normal -slant roman -underline 0 -overstrike 0 diff --git a/git/.gitconfig.d/40-github b/git/.gitconfig.d/40-github deleted file mode 100644 index 427cffa..0000000 --- a/git/.gitconfig.d/40-github +++ /dev/null @@ -1,2 +0,0 @@ -[github] - user = mitchty diff --git a/git/.gitconfig.d/50-gpg b/git/.gitconfig.d/50-gpg deleted file mode 100644 index 98c654c..0000000 --- a/git/.gitconfig.d/50-gpg +++ /dev/null @@ -1,2 +0,0 @@ -[credential] - helper = netrc -v -f ~/.netrc.gpg -f ~/.netrc diff --git a/git/.gitconfig.d/50-http b/git/.gitconfig.d/50-http deleted file mode 100644 index 4a4f009..0000000 --- a/git/.gitconfig.d/50-http +++ /dev/null @@ -1,4 +0,0 @@ -[http] - postBuffer = 209715200 -[push] - default = simple diff --git a/git/.gitignore b/git/.gitignore deleted file mode 100644 index 5ba8a88..0000000 --- a/git/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -.*~ -*~ -.\#* -\#* -\#*\# -.\#*\# -.DS_Store -*.pyc -*.rbc -*.elc -*.swp -*.[oa] diff --git a/git/.profile.d/20-functions-git.sh b/git/.profile.d/20-functions-git.sh deleted file mode 100644 index 5ef4a6e..0000000 --- a/git/.profile.d/20-functions-git.sh +++ /dev/null @@ -1,40 +0,0 @@ -# git/.profile.d/20-functions-git.sh -maybe_git_repo() -{ - # assume https if input doesn't contain a protocol - proto=https - destination=${HOME}/src - echo "${1}" | grep '://' > /dev/null 2>&1 - [ $? = 0 ] && proto=$(echo "${1}" | sed -e 's|[:]\/\/.*||g') - git_dir=$(echo "${1}" | sed -e 's|.*[:]\/\/||g') - rrepo="${proto}://${git_dir}" - - # strip user@, :NNN, and .git from input uri's - repo="${destination}/"$(echo "${git_dir}" | - sed -e 's/\.git$//g' | - sed -e 's|.*\@||g' | - sed -e 's|\:[[:digit:]]\{1,\}\/|/|g' | - tr -d '~') - - if [ ! -d "${repo}" ]; then - git ls-remote "${rrepo}" > /dev/null 2>&1 - if [ $? = 0 ]; then - mkdir -p "${repo}" - echo "git clone ${rrepo} ${repo}" - git clone "${rrepo}" "${repo}" - else - echo "${rrepo} doesn't look to be a git repository" - fi - fi - [ -d "${repo}" ] && cd "${repo}" -} - -gh() -{ - maybe_git_repo "https://github.com/${1}" -} - -bb() -{ - maybe_git_repo "https://bitbucket.org/${1}" -} diff --git a/git/.profile.d/99-alias-git.sh b/git/.profile.d/99-alias-git.sh deleted file mode 100644 index bc04c55..0000000 --- a/git/.profile.d/99-alias-git.sh +++ /dev/null @@ -1,2 +0,0 @@ -# git/.profile.d/99-alias-git.sh -alias g=git diff --git a/haskell/.ghc.hs b/haskell/.ghc.hs deleted file mode 100644 index 7c493b3..0000000 --- a/haskell/.ghc.hs +++ /dev/null @@ -1,8 +0,0 @@ -import Control.Applicative -import Control.Monad -import Data.Monoid -import Data.Maybe -import Data.List -import Data.Bool -import qualified Data.Set as S -import qualified Data.Map as M diff --git a/haskell/.ghci b/haskell/.ghci deleted file mode 100644 index 3a3eda1..0000000 --- a/haskell/.ghci +++ /dev/null @@ -1,3 +0,0 @@ -:l ~/.ghc.hs -:set prompt "λ " -:set +t diff --git a/haskell/.profile.d/10-path-haskell.sh b/haskell/.profile.d/10-path-haskell.sh deleted file mode 100644 index e27f8eb..0000000 --- a/haskell/.profile.d/10-path-haskell.sh +++ /dev/null @@ -1,3 +0,0 @@ -# haskell/.profile.d/10-path-haskell.sh -PATH="${PATH}:${HOME}/.cabal/bin" -export PATH diff --git a/haskell/.profile.d/20-functions-haskell.sh b/haskell/.profile.d/20-functions-haskell.sh deleted file mode 100644 index 7b43c71..0000000 --- a/haskell/.profile.d/20-functions-haskell.sh +++ /dev/null @@ -1,15 +0,0 @@ -# haskell/.profile.d/20-functions-haskell.sh -hmap() -{ - ghc -e "interact ($*)" -} - -hmapl() -{ - hmap "unlines.($*).lines" -} - -hmapw() -{ - hmapl "map (unwords.($*).words)" -} diff --git a/haskell/.profile.d/99-alias-haskell.sh b/haskell/.profile.d/99-alias-haskell.sh deleted file mode 100644 index 596828c..0000000 --- a/haskell/.profile.d/99-alias-haskell.sh +++ /dev/null @@ -1,2 +0,0 @@ -# haskell/.profile.d/99-alias-haskell.sh -alias ghce="ghc -e ':l ~/.ghc.hs' -e" diff --git a/mosh/.profile.d/99-alias-mosh.sh b/mosh/.profile.d/99-alias-mosh.sh deleted file mode 100644 index 44d590f..0000000 --- a/mosh/.profile.d/99-alias-mosh.sh +++ /dev/null @@ -1,2 +0,0 @@ -# mosh/.profile.d/99-alias-mosh.sh -alias m=mosh diff --git a/nix/.nixpkgs/config.nix b/nix/.nixpkgs/config.nix deleted file mode 100644 index 3635799..0000000 --- a/nix/.nixpkgs/config.nix +++ /dev/null @@ -1,127 +0,0 @@ -{pkgs}: { - allowUnfree = true; - allowBroken = true; - - packageOverrides = pkgs: with pkgs; { - pinentry = pkgs.pinentry.override { - gtk2 = null; - qt4 = null; - ncurses = null; - }; - gnupg = pkgs.gnupg.override { - x11Support = false; - pinentry = true; - }; - youtube-dl = pkgs.youtube-dl.override { - pandoc = null; - }; - - # haskellPackages = haskellPackages.override { - # extension = self : super : { - # cabal = pkgs.haskellPackages.cabalNoTest; - # }; - # }; - - default = with pkgs; buildEnv { - - name = "default"; - - paths = [ - ansible - ack - aria - iperf - cacert - curl - clang - clang-analyzer - diffutils - patchutils - gitAndTools.gitFull - gitAndTools.git-extras - bazaarTools - mercurial - subversionClient - gist - mercurial - docbook5 - entr - emacs - gnupg1compat - gnutar - gnumake - sloccount - cloc - less - multitail - rlwrap - gdbm - mosh - htop - imagemagick - keychain - silver-searcher - aspell - aspellDicts.en - openssl - pinentry - pbzip2 - pigz - pv - postgresql - readline - rsync - sqlite - texLiveFull - tmux - tree - wget - wakelan - unzip - upx - xz - p7zip - unrar - watch - nox - mutt - duply - zsh - pylint - python27Packages.howdoi - python27Packages.youtube-dl - python27Packages.pyflakes - python27Packages.flake8 - python27Packages.virtualenv - python27Packages.pip -# xhyve compiles normally, figure out hypervisor framework issue -# lastpass-cli no worky on osx TODO fix this it works on homebrew - ]; - }; - env_hs = - pkgs.haskell.packages.ghc7102.ghcWithPackages - (haskellPackages: with haskellPackages; [ - alex - happy - bake - cabal-dependency-licenses - cabal-install - cabal-meta - ghc-core - ghc-mod - hasktags - hindent - hoogle - hspec - idris - pandoc - shake - ShellCheck - stack - stylish-haskell - nats - transformers-compat - ] - ); - }; -} diff --git a/nix/.profile.d/20-functions-nix.sh b/nix/.profile.d/20-functions-nix.sh deleted file mode 100644 index bca2c98..0000000 --- a/nix/.profile.d/20-functions-nix.sh +++ /dev/null @@ -1,16 +0,0 @@ -# nix/.profile.d/20-functions-nix.sh -mk_nix_shell() -{ - cabal2nix --sha256="0" . \ - | perl -0777 -p -e 's/{.+}:/{ haskellPackages ? (import {}).haskellPackages }:/s' \ - | sed -E -e 's/(cabal\.mkDerivation)/with haskellPackages; \1/' -e 'sXsha256 = "0";Xsrc = "./.";X' \ - > shell.nix; -} - -nix_env_setup() -{ - NIX_GHC=$(type -p ghc > /dev/null 2>&1) - if [ -n "$NIX_GHC" ]; then - eval $(grep export "$NIX_GHC") - fi -} diff --git a/nix/.profile.d/99-final-nix.sh b/nix/.profile.d/99-final-nix.sh deleted file mode 100755 index 638e493..0000000 --- a/nix/.profile.d/99-final-nix.sh +++ /dev/null @@ -1,25 +0,0 @@ -# nix/profile.d/99-final-nix.sh - -nix_env_setup() -{ - # The nix installer put something like this into the .profile. - # BAD INSTALLER NO COOKIE! - if [ -e ${HOME}/.nix-profile/etc/profile.d/nix.sh ]; then - . ${HOME}/.nix-profile/etc/profile.d/nix.sh; - export NIX_PATH=${HOME}/src/github.com/NixOS/nixpkgs:nixpkgs=${HOME}/src/github.com/NixOS/nixpkgs - export NIX_CFLAGS_COMPILE="-idirafter /usr/include" - export NIX_CFLAGS_LINK="-L/usr/lib" - - NIX_GHC=$(type -p ghc > /dev/null 2>&1) - if [ -n "$NIX_GHC" ]; then - eval $(grep export "$NIX_GHC") - fi - fi - - nr() - { - nix-shell --run "$(echo $@)" - } -} - -nix_env_setup diff --git a/options.el b/options.el new file mode 100644 index 0000000..8522a44 --- /dev/null +++ b/options.el @@ -0,0 +1,24 @@ +;;-*-mode: emacs-lisp; coding: utf-8;-*- +;; All these variables control what/how readme.org gets tangled +;; into dotfiles. Off by default set to t to turn them on as +;; needed. + +;; OS types +(setq bsd-p nil) +(setq linux-p nil) +(setq osx-p nil) + +;; Optional things +(setq nix-p nil) +(setq tmux-p nil) +(setq git-p nil) +(setq emacs-p nil) +(setq vim-p nil) +(setq zsh-p nil) +(setq mosh-p nil) +(setq x-p nil) + +;; Language specific +(setq haskell-p nil) +(setq perl-p nil) +(setq ruby-p nil) diff --git a/osx.el b/osx.el new file mode 100644 index 0000000..fd38aec --- /dev/null +++ b/osx.el @@ -0,0 +1,24 @@ +;;-*-mode: emacs-lisp; coding: utf-8;-*- +;; All these variables control what/how readme.org gets tangled +;; into dotfiles. Off by default set to t to turn them on as +;; needed. + +;; OS types +(setq bsd-p nil) +(setq linux-p nil) +(setq osx-p t) + +;; Optional things +(setq nix-p t) +(setq tmux-p t) +(setq git-p t) +(setq emacs-p t) +(setq vim-p nil) +(setq zsh-p t) +(setq mosh-p t) +(setq x-p t) + +;; Language specific +(setq haskell-p t) +(setq perl-p t) +(setq ruby-p nil) diff --git a/osx/.profile.d/01-ps1-osx.sh b/osx/.profile.d/01-ps1-osx.sh deleted file mode 100644 index 29224e2..0000000 --- a/osx/.profile.d/01-ps1-osx.sh +++ /dev/null @@ -1,3 +0,0 @@ -# osx/.profile.d/01-ps1-osx.sh -_host=$(hostname -s) -export _host diff --git a/osx/.profile.d/10-path-osx.sh b/osx/.profile.d/10-path-osx.sh deleted file mode 100644 index c9eb90f..0000000 --- a/osx/.profile.d/10-path-osx.sh +++ /dev/null @@ -1,5 +0,0 @@ -# osx/.profile.d/10-path-osx.sh -osx_release=$(sw_vers -productVersion | sed -e 's/\.[0-9]\{1\}//2') -brew_home=/usr/local/brew/${osx_release} -PATH="${brew_home}/bin:/usr/local/bin:${PATH}" -export PATH diff --git a/osx/.profile.d/99-alias-osx.sh b/osx/.profile.d/99-alias-osx.sh deleted file mode 100644 index c83ee9f..0000000 --- a/osx/.profile.d/99-alias-osx.sh +++ /dev/null @@ -1,2 +0,0 @@ -# osx/.profile.d/99-alias.sh -alias o='open -a' diff --git a/perl/.perlcriticrc b/perl/.perlcriticrc deleted file mode 100644 index f986d16..0000000 --- a/perl/.perlcriticrc +++ /dev/null @@ -1,49 +0,0 @@ -# Show the severity level -severity = 1 - -# Basically show what profile is complaining -verbose = %f:%l:%c: %m, %e (%p, severity %s)\n - -# Don't warn on these variables -[Variables::ProhibitPunctuationVars] -allow = $@ $! - -# Ignore syscall returns on print, it not actually returning is... whatever. -[InputOutput::RequireCheckedSyscalls] -exclude_functions = print say - -# Allow things like print qx(somecmd) in a void context to work, this is ok. -[InputOutput::ProhibitBacktickOperators] -only_in_void_context = 1 - -# I actually like using unless... so don't piss me off whinging about it -[-ControlStructures::ProhibitUnlessBlocks] - -# The following only apply to modules -[-Modules::RequireVersionVar] -[-ErrorHandling::RequireCarping] - -# Tabs suck, no -[CodeLayout::ProhibitHardTabs] -allow_leading_tabs = 0 - -# For small regexes, no /x at the end is fine, 12 should be enough -[RegularExpressions::RequireExtendedFormatting] -minimum_regex_length_to_complain_about = 12 - -# These are kosher kthxbai -[ControlStructures::ProhibitPostfixControls] -allow = for if until unless - -# For POE, we do things like my $foo = $_[HEAP]; and thats OK -[Subroutines::RequireArgUnpacking] -allow_subscripts = 1 - -# For POD documentation, I don't care about required sections. -[Documentation::RequirePodSections] -lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT | SEE ALSO -script_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT | SEE ALSO - -# This is for POD documentation mainly. -[CodeLayout::ProhibitHardTabs] -allow_leading_tabs = 1 diff --git a/perl/.perltidyrc b/perl/.perltidyrc deleted file mode 100644 index 73c1753..0000000 --- a/perl/.perltidyrc +++ /dev/null @@ -1,22 +0,0 @@ -# cuddled elses pls --ce -# indent 2 spaces --i=2 -# for tokens with things like arrays, start the data next line down one indent in --lp -# align closing tokens for things like arrays with the opening token --cti=1 -# default, but spaces between multiple entries, none with one arg --pt=1 -# line encoding --ole=unix -# braces not on new line --nsbl -# stack opening tokens, don't create a new line with one token, note no stacking of closing tokens --sot -# no space before ;'s in for loops --nsfs -# Make curly braces act more like the args param --bbt=1 -# Trim qw whitespaces --tqw diff --git a/perl/.profile.d/99-alias-perl.sh b/perl/.profile.d/99-alias-perl.sh deleted file mode 100644 index c4a7ec2..0000000 --- a/perl/.profile.d/99-alias-perl.sh +++ /dev/null @@ -1,2 +0,0 @@ -# perl/.profile.d/99-alias-perl.sh -alias p=perl diff --git a/readme.org b/readme.org new file mode 100644 index 0000000..bcffe93 --- /dev/null +++ b/readme.org @@ -0,0 +1,2375 @@ +#+TITLE: Dotfiles Everywhere +#+AUTHOR: Mitch Tishmack +#+STARTUP: hidestars +#+STARTUP: odd +#+BABEL: :cache yes +#+PROPERTY: header-args :tangle yes :comments no :padline no + +In the long long ago (2015), I used xstow and update-dotdee to construct my +dotfiles from tiny pieces of files. + +I have since evolved to this setup. Originally the intention was to make it easy +for me to compile dotfiles based on certain parameters. Aka, my dotfiles are the +same for x, y, and z, whatever those are, but for certain cases z should have +one section be different or added etc... as the case may be. + +Aka it was just a glorified program or templating system. + +Since I already use org-mode to build my emacs configuration, +why not just do the same for the dotfiles. Bonus, now I can have ALL +my dotfiles in one logical file that can build itself. + +So now if you want to look at my dotfiles, they're all in here. With one +caveat that my emacs configuration is not. That is still separate, I might +change that at some point in the future, but that day is not today. + +* Use + +Use of this setup is simple. There really is one step: +- make + +??? HOW ??? + +Well the Makefile is pretty basic, start there. But generally here is how +the sausage is being made. + +There are a couple helper scripts: +- etangle, aka emacs tangle, which is just a wrapper around emacs+org for + the commandline/makefile to use. +- ddiff, a rather stupid shell script that recursively diffs directory a + to directory b, ignoring files that do not exist in directory b but + exist in a (aka new files). + +NOTE: Removal of files is YOUR job, not this thing. One could +theoretically look at what changed between two generations and +remove that. BUT that sounds janky and error prone. Removal of +files is the users job, not this setup. + +** Explanation of what is happening + +The prelude controls org variables that change how files get tangled to files. + +This allows me to tangle files that would be useful for linux/bsd/etc... +without affecting the existing files. + +The general idea is this (look at Makefile for details): +- increment generation count from last generation +- tangle files to tmp/$filename based on current settings +- copy tmp to generation/N +- iff generation/(N-1) exists, diff each file there to what exists at DEST +- If diffing fails, the destination files have been updated, STOP, might lose + hand edited changes. Note, if destination does not exist, this is ignored. + Also setting FORCE will ignore this check. +- If diffing does not fail, hardlink generation/N/$files to DEST/$files +- Update last with current generation. + +Note, the destination can be anywhere, not just $HOME. This allows one to +compile/tangle files that can then be trivially rsynced to remote machines, +or to tar/xz the files as needed. The key here is emacs is only required +to generate config files. + +* ~/.profile +:PROPERTIES: +:header-args: :tangle tmp/.profile :comments no :padline no :cache yes :mkdirp yes +:END: + +** PS1 + +#+BEGIN_SRC sh +# -*- mode: Shell-script; -*- +# Common .profile +# +# DO NOT EDIT, managed by org mode +_uname=$(uname) +_uname_n=$(uname -n) +_hostname=$(hostname) +export _uname _uname_n _hostname +#+END_SRC + +OSX uses hostname -s for getting hostname + +#+BEGIN_SRC sh :tangle (when (eq osx-p t) "tmp/.profile") +_host=$(hostname -s) +#+END_SRC + +Otherwise we just use what uname -n sent. + +#+BEGIN_SRC sh +_host=${_host:=${_uname_n}} +#+END_SRC + +** PATH +*** osx +OSX homebrew leftovers, need to make sure it make sense any longer as I've switched to nix. + +#+BEGIN_SRC sh :tangle (when (eq osx-p t) "tmp/.profile") +osx_release=$(sw_vers -productVersion | sed -e 's/\.[0-9]\{1\}//2') +brew_home=/usr/local/brew/${osx_release} +PATH="${brew_home}/bin:/usr/local/bin:${PATH}" +export PATH +#+END_SRC +*** haskell +#+BEGIN_SRC sh :tangle (when (eq haskell-p t) "tmp/.profile") +PATH="${PATH}:${HOME}/.cabal/bin" +#+END_SRC +*** General +#+BEGIN_SRC sh :tangle "tmp/.profile" +PATH="${PATH}:${HOME}/bin" +export PATH +#+END_SRC + +** Functions +*** General +Generally useful functions. + +#+BEGIN_SRC sh +# cat out a : separated env variable +# variable is the parameter +cat_env() +{ + set | grep '^'"$1"'=' > /dev/null 2>&1 && eval "echo \$$1" | tr ':' ' +' | awk '!/^\s+$/' | awk '!/^$/' +} + +# Convert a line delimited input to : delimited +to_env() +{ + awk '!a[$0]++' < /dev/stdin | tr -s ' +' ':' | sed -e 's/\:$//' | awk 'NF > 0' +} + +# Unshift a new value onto the env var +# first arg is ENV second is value to unshift +# basically prepend value to the ENV variable +unshift_env() +{ + new=$(eval "echo $2; echo \$$1" | to_env) + eval "$1=${new}; export $1" +} + +# Opposite of above, but echos what was shifted off +shift_env() +{ + first=$(cat_env "$1" | head -n 1) + rest=$(cat_env "$1" | awk '{if (NR!=1) {print}}' | to_env) + eval "$1=$rest; export $1" + echo "${first}" +} + +# push $2 to $1 on the variable +push_env() +{ + have=$(cat_env "$1") + new=$(printf "%s +%s" "$have" "$2" | to_env) + eval "$1=$new; export $1" +} + +# Remove a line matched in $HOME/.ssh/known_hosts for when there are legit +# host key changes. +nukehost() +{ + if [ -z "$1" ]; then + echo "Usage: nukehost " + echo " Removes from ssh known_host file." + else + sed -i -e "/$1/d" ~/.ssh/known_hosts + fi +} + +# Cheap copy function to make copying a file via ssh from one host +# to another less painful, use pipeviewer to give some idea as to progress. +ssh-copyfile() +{ + if [ -z "$1" -o -z "$2" ]; then + echo "Usage: copy source:/file/location destination:/file/location" + else + srchost="$(echo "$1" | awk -F: '{print $1}')" + src="$(echo "$1" | awk -F: '{print $2}')" + dsthost="$(echo "$2" | awk -F: '{print $1}')" + dst="$(echo "$2" | awk -F: '{print $2}')" + size=$(ssh "$srchost" du -hs "$src" 2> /dev/null) + size=$(echo "${size}" | awk '{print $1}') + echo "Copying $size to $dst" + ssh "$srchost" "/bin/cat \$src" 2> /dev/null | pv -cb -N copied - | ssh "$dsthost" "/bin/cat - > \$dst" 2> /dev/null + fi +} + +# extract function to automate being lazy at extracting archives. +extract() +{ + if [ -f "$1" ]; then + case ${1} in + *.tar.bz2|*.tbz2|*.tbz) bunzip2 -c "$1" | tar xvf -;; + *.tar.gz|*.tgz) gunzip -c "$1" | tar xvf -;; + *.tz|*.tar.z) zcat "$1" | tar xvf -;; + *.tar.xz|*.txz|*.tpxz) xz -d -c "$1" | tar xvf -;; + *.bz2) bunzip2 "$1";; + *.gz) gunzip "$1";; + *.jar|*.zip) unzip "$1";; + *.rar) unrar x "$1";; + *.tar) tar -xvf "$1";; + *.z) uncompress "$1";; + *.rpm) rpm2cpio "$1" | cpio -idv;; + *) echo "Unable to extract <$1> Unknown extension." + esac + else + print "File <$1> does not exist." + fi +} + +# Tcsh compatibility so I can be a lazy bastard and paste things directly +# if/when I need to. +setenv() +{ + export "$1=$2" +} + +# Just to be lazy, set/unset the DEBUG env variable used in my scripts +debug() +{ + if [ -z "$DEBUG" ]; then + if [ -z "$1" ]; then + echo Setting DEBUG to "$1" + setenv DEBUG "$1" + else + echo Setting DEBUG to default + setenv DEBUG default + fi + else + echo Unsetting DEBUG + unset DEBUG + fi +} + +login_shell() +{ + [ "$-" = "*i*" ] +} + +# Yeah, sick of using the web browser for this crap +# Use is NUM FROM TO and boom get the currency converted from goggle. +cconv() +{ + curl -L --silent\ + "https://www.google.com/finance/converter?a=$1&from=$2&to=$3" \ + | grep converter_result \ + | perl -pe 's|[<]\w+ \w+[=]\w+[>]||g;' -e 's|[<][/]span[>]||' +} +#+END_SRC + +*** git +#+BEGIN_SRC sh :tangle (when (eq git-p t) "tmp/.profile") +maybe_git_repo() +{ + # assume https if input doesn't contain a protocol + proto=https + destination=${HOME}/src + echo "${1}" | grep '://' > /dev/null 2>&1 + [ $? = 0 ] && proto=$(echo "${1}" | sed -e 's|[:]\/\/.*||g') + git_dir=$(echo "${1}" | sed -e 's|.*[:]\/\/||g') + rrepo="${proto}://${git_dir}" + + # strip user@, :NNN, and .git from input uri's + repo="${destination}/"$(echo "${git_dir}" | + sed -e 's/\.git$//g' | + sed -e 's|.*\@||g' | + sed -e 's|\:[[:digit:]]\{1,\}\/|/|g' | + tr -d '~') + + if [ ! -d "${repo}" ]; then + git ls-remote "${rrepo}" > /dev/null 2>&1 + if [ $? = 0 ]; then + mkdir -p "${repo}" + echo "git clone ${rrepo} ${repo}" + git clone "${rrepo}" "${repo}" + else + echo "${rrepo} doesn't look to be a git repository" + fi + fi + [ -d "${repo}" ] && cd "${repo}" +} + +gh() +{ + maybe_git_repo "https://github.com/${1}" +} + +bb() +{ + maybe_git_repo "https://bitbucket.org/${1}" +} +#+END_SRC +*** haskell +#+BEGIN_SRC sh :tangle (when (eq haskell-p t) "tmp/.profile") +hmap() +{ + ghc -e "interact ($*)" +} + +hmapl() +{ + hmap "unlines.($*).lines" +} + +hmapw() +{ + hmapl "map (unwords.($*).words)" +} +#+END_SRC +*** nix +#+BEGIN_SRC sh :tangle (when (eq nix-p t) "tmp/.profile") +mk_nix_shell() +{ + cabal2nix --sha256="0" . \ + | perl -0777 -p -e 's/{.+}:/{ haskellPackages ? (import {}).haskellPackages }:/s' \ + | sed -E -e 's/(cabal\.mkDerivation)/with haskellPackages; \1/' -e 'sXsha256 = "0";Xsrc = "./.";X' \ + > shell.nix; +} + +nix_env_setup() +{ + # The nix installer put something like this into the .profile. + # BAD INSTALLER NO COOKIE! + if [ -e ${HOME}/.nix-profile/etc/profile.d/nix.sh ]; then + . ${HOME}/.nix-profile/etc/profile.d/nix.sh; + export NIX_PATH=${HOME}/src/github.com/NixOS/nixpkgs:nixpkgs=${HOME}/src/github.com/NixOS/nixpkgs + export NIX_CFLAGS_COMPILE="-idirafter /usr/include" + export NIX_CFLAGS_LINK="-L/usr/lib" + + NIX_GHC=$(type -p ghc > /dev/null 2>&1) + if [ -n "$NIX_GHC" ]; then + eval $(grep export "$NIX_GHC") + fi + fi + + nr() + { + nix-shell --run "$(echo $@)" + } +} + +nix_env_setup +#+END_SRC +*** tmux +#+BEGIN_SRC sh :tangle (when (eq tmux-p t) "tmp/.profile") +t() +{ + if [ -z "$1" ]; then + echo "Supply a tmux session name to connect to/create" + else + tmux has-session -t "$1" 2>/dev/null + [ $? != 0 ] && tmux new-session -d -s "$1" + tmux attach-session -d -t "$1" + fi +} +#+END_SRC +*** x +#+BEGIN_SRC sh :tangle (when (eq x-p t) "tmp/.profile") +modmap() +{ + [ -f "${HOME}/.Xmodmap" ] && xmodmap "${HOME}/.Xmodmap" +} +#+END_SRC +** Aliases +*** General +#+BEGIN_SRC sh +# general aliases +alias s="\$(which ssh)" +alias quit='exit' +alias cr='reset; clear' +alias a=ag +alias n=noglob +alias l=ls +alias L='ls -dal' +alias cleandir="find . -type f \( -name '*~' -o -name '#*#' -o -name '.*~' -o -name '.#*#' -o -name 'core' -o -name 'dead.letter*' \) | grep -v auto-save-list | xargs -t rm" + +# Prefer less for paging duties. +which less > /dev/null 2>&1 +if [ $? -eq 0 ]; then + alias T="\$(which less) -f +F" +else + alias T="\$(which tail) -f" +fi +#+END_SRC + +*** osx +#+BEGIN_SRC sh :tangle (when (eq osx-p t) "tmp/.profile") +alias o='open -a' +#+END_SRC +*** git +#+BEGIN_SRC sh :tangle (when (eq git-p t) "tmp/.profile") +alias g=git +#+END_SRC +*** haskell +#+BEGIN_SRC sh :tangle (when (eq haskell-p t) "tmp/.profile") +alias ghce="ghc -e ':l ~/.ghc.hs' -e" +#+END_SRC +*** mosh +#+BEGIN_SRC sh :tangle (when (eq mosh-p t) "tmp/.profile") +alias m=mosh +#+END_SRC + +*** tmux +#+BEGIN_SRC sh :tangle (when (eq tmux-p t) "tmp/.profile") +alias tl='tmux ls' +#+END_SRC +* ~/bin + +** ~/bin/cidr + +A stupid script I wrote ages ago to help me be lazy with cidr +notation for stuff. Setup the wrong netmask a few times and +you too, will wish for something similar. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/cidr :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Convert input ip/cidr|netmask|hexnetmask to useable network information. +# + +use strict; +use warnings; +use Socket; +use Sys::Hostname; + +# +# Globalish vars +# +$ENV{PATH} = '/usr/bin:/bin:/usr/sbin:/sbin'; # Paranoia, know thy name! +my ($fqdn_regexp) = qr/([0-9,a-z,A-Z,\-,\_]+)\.([0-9,a-z,A-Z,\-,\_]+)\.(com|gov)/; + +# +# converts a 1-word (4 byte) signed or unsigned integer into a dotted decimal +# ip address. +# +sub int2ip { + my $n=int(pop); + return(sprintf("%d.%d.%d.%d", ($n>>24)&0xff,($n>>16)&0xff, + ($n>>8)&0xff,$n&0xff)); +}; + +# +# Convert a host/ip/netmask/cidr/etc.... to a hash of information +# Example: host.domain.tld/24 will get the ip and calculate the netmask info +# equally if host.domain.tld corresponds with 1.2.3.4 the following is valid +# 1.2.3.4/255.255.255.0 would obtain the same information. +# +# die()'s if anything isn't kosher. +# +# Ultra long function, probably needs to be looked at for condensing/splitting. +# +sub cidr2raw { + my $rawinput = pop; + my ($lhs, $rhs, $j, $uip) = (undef, undef, undef, undef); + my ($ucidr) = 0; + my ($network, $bits, $netmask, $broadcast, $low, $high); + + if ($rawinput =~ qr/(.*)\/(.*)/){ + $lhs = $1; $rhs = $2; + }else{ + die "Input: $rawinput not expected.\n"; + }; + + # + # Handle ip/hostname for left hand side. + if ($lhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ + foreach my $dotted (($1,$2,$3,$4)){ + if (($dotted > 255) or ($dotted < 0)){ + die "FATAL: ipv4 address entered, $lhs entered is impossible, $dotted is not between 0-255.\n"; + }; + }; + $uip = inet_ntoa(scalar gethostbyname($lhs)); + die "FATAL: Cannot determine hostname for $lhs$!\n" if (!defined($lhs)); + }elsif ($lhs =~ $fqdn_regexp){ + my $tmp = gethostbyname($lhs); + die "FATAL: Cannot determine ip for $lhs" if (!defined($tmp)); + $uip = inet_ntoa($tmp); + }else{ + die "FATAL: host value not fully qualified, or not an ip <$lhs>\n"; + }; + + # + # Handle the netmask/cidr for the right hand side, + # + # All input netmasks are converted to a cidr address for notation + if ($rhs =~ qr/^(\d+)$/){ # /cidr + $ucidr = $1; + die "FATAL: Invalid CIDR <$ucidr>.$!\n" if (($ucidr > 32) or ($ucidr < 0)); + }elsif ($rhs =~ qr/(0[xX])?([0-9,a-f,A-F]{7})/){ # /0xhexnetmask + my $trimmed = $2; + my $insane = 0; + foreach my $byte (split('', unpack("B32", pack("H*", $trimmed)))){ + ($byte) ? $ucidr++ : $insane++; + die "FATAL: $rhs is not a valid hex netmask.$!\n" if ($insane and $byte); + }; + }elsif ($rhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ # /255.255.255.0 form + my @a = ($1, $2, $3, $4); + my $insane = 0; + foreach my $t (@a){ + die "FATAL: Netmask out of range. Input <$rhs> Invalid <$t>$!\n" if (($t < 0) or ($t > 255)); + }; + foreach my $byte (split('', unpack("B32", pack("C4", @a)))){ + ($byte) ? $ucidr++ : $insane++; + die "FATAL: $rhs is not a valid netmask.$!\n" if ($insane and $byte); + }; + }else{ + die "FATAL: Unknown or invalid netmask value entered. <$rhs>\n"; + }; + + # + # Network math GO! This is the meat of the function. + my (@uip) = split(/\./, $uip); + $network = 0; + for ($j = 0; $j <= $#uip; $j++){ + $network += int($uip[$j])<<((3-$j)*8); + }; + + $bits = 0; $j = 0; + for ($j = 31 - $ucidr; $j >= 0; $j--){ + $bits |= 1<<$j; + }; + + $netmask = 0xffffffff^$bits; + $low = ($network&$netmask); + $high = ($network&$netmask)+$bits-1; + $broadcast = ($network&$netmask)|$bits; + my ($guessed_hostname,undef,undef,undef,undef) = gethostbyaddr(inet_aton($uip), AF_INET); + + # + # Throw the info back, they get a hash with zie info they may/may not need. + # All up to the caller what they want to use. + # + return ("inet4" => $uip, + "netmask" => int2ip($netmask), + "broadcast" => int2ip($broadcast), + "cidr" => $ucidr, + "router" => int2ip($low+1), + "network" => int2ip($low), + "high" => int2ip($high), + "hostname" => $guessed_hostname, + ); +}; + +#package Main; # future use + +foreach my $arg (@ARGV){ + my %stuff = cidr2raw($arg); + printf("%s/%s is %s/%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n", + $stuff{"inet4"},$stuff{"cidr"}, + $stuff{"network"},$stuff{"cidr"}, + "Netmask",$stuff{"netmask"}, + "Broadcast",$stuff{"broadcast"}, + "Network",$stuff{"network"}, + "Router",$stuff{"router"}, + "HighUsable",$stuff{"high"}, + ); +}; +#+END_SRC + +** ~/bin/dns + +Just a silly dns script that slighly mimics the old host utility +of yore. Can also do reverse lookups. + +Example: +$ dns google.com +google.com is 216.58.216.206 +google.com is also google.com +$ dns 216.58.216.206 +ord31s21-in-f206.1e100.net is 216.58.216.206 +ord31s21-in-f206.1e100.net is also ord31s21-in-f206.1e100.net + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/dns :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Stupid script to help with dns information. Solaris 9/8 lack the host utility. +# Which this (kinda) mimics, except the mx record crap +use strict; +use warnings; +use Socket; +use Sys::Hostname; + +my $input = shift || hostname(); +my $lookup = $input; + +if ( $lookup =~ /\d+[.]\d+[.]\d+[.]\d+/smx ) { + $lookup = ( gethostbyaddr inet_aton($lookup), AF_INET )[0]; + die "Error: Unable to reverse lookup ip $input.\n" if ( $lookup eq q{} ); +} + +my $ipv4 = gethostbyname $lookup; + +die "Error: $lookup doesn't have any known ip addresses\n" + if ( !defined $ipv4 ); + +$ipv4 = inet_ntoa($ipv4); + +my ( $short_name, $aliases, $addrtype, $len, @addrs ) = gethostbyname $lookup; + +foreach my $ipv4 (@addrs) { + $ipv4 = inet_ntoa($ipv4); + print "$lookup is $ipv4\n"; +} + +print "$lookup is also $short_name\n"; +if ( defined $aliases and "$aliases" ne q{} ) { + print "aliases are ($aliases)\n"; +} +exit 0; +#+END_SRC + +** ~/bin/ts + +Stupid simple timestamp script that just takes input, and prefixes a timestamp to to output. Thats it. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/ts :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Timestamp stdin and then print to stdout and flush. +# +# Thats about it. Might add a quick and dirty option to allow you to +# specify the time output whatnot. But this is intended to be simple. +use strict; +use warnings; +use POSIX qw(strftime); +use IO::Handle; +STDOUT->autoflush(1); + +while(){ + my $now = time; + my $tz = strftime(('%z', (localtime $now))); + $tz =~ s/(\d{2})(\d{2})/$1:$2/smx; + my $time = strftime('%Y-%m-%dT%H:%M:%S', (localtime $now)); + print "$time$tz ".$_; +}; +#+END_SRC + +** ~/bin/diskhog + +Old script I wrote after I had to figure out where space was used and it was mostly all in a directory with a ton of small files. + +Written in anger. Not all that useful nominally. + +Defaults to /tmp if you don't specify where, also defaults to the top 10 offenders/users of space. + +Its not particuarly bright, or even good code. If you want ALL THE THINGS, pass -n -1 in and you will get a ton of output. Good luck with that. + +Example: +$ diskhog +1.79m /private/tmp +1.38m /private/tmp/wifi-Ea5Y9F.log +420.57k /private/tmp/sysp.xml +161.17k /private/tmp/KSOutOfProcessFetcher.12572.ppfIhqX0vjaTSb8AJYobDV7Cu68=/ksfetch +161.17k /private/tmp/KSOutOfProcessFetcher.12572.ppfIhqX0vjaTSb8AJYobDV7Cu68= +0.00k /private/tmp/com.apple.launchd.yaVsd6J1re +0.00k /private/tmp/cvcd +0.00k /private/tmp/com.apple.launchd.IPS1lPqGTD +0.00k /private/tmp/com.apple.launchd.voZH6WFol3 +0.00k /private/tmp/ct.shutdown +$ diskhog -n 4 /tmp +1.79m /private/tmp +1.38m /private/tmp/wifi-Ea5Y9F.log +420.57k /private/tmp/sysp.xml +161.17k /private/tmp/KSOutOfProcessFetcher.12572.ppfIhqX0vjaTSb8AJYobDV7Cu68= + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/diskhog :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Find out who is hogging disk space and where. +# +# Argument is the directory to start from. Only calculates size of files. +# Adds the size of files in a directory to the size of the parent directory only. +# +# Defaults to top 10 directories/files. +# +# Override with -n num to list whatever amount of large things you desire. +# Or if you want to abuse the parser, use -1 for all files/directories. +# +# Defaults to pwd for space. +# + +use File::Find; +use Getopt::Long; +use Cwd; + +my $debug; +my $statbug; +(exists($ENV{"DEBUG"})) ? $debug++ : undef; +my $dir = Cwd::abs_path($ARGV[-1] || Cwd::getcwd()); +my %diskhogs = (); +my %inodes = (); +my ($topdev,undef,undef,undef,undef,undef,undef,undef) = lstat($dir); +local $opt_displaynum = 10; + +GetOptions( 'n=i', => \$opt_displaynum, + ); + +find(\&sieve, $dir); + +# +# For outputing the size of a bunch of bytes in g/m/k depending upon the size +# +sub byte_print { + my $byte_k = 1_024; + my $byte_m = $byte_k**2; + my $byte_g = $byte_k**3; + my $bytes = pop; + my $base = $bytes; + my $suffix = "nil"; + my $out_string = "BUG"; + if($bytes > $byte_g){ + $base = $bytes / $byte_g; + $suffix = "g"; + }elsif($bytes > $byte_m){ + $base = $bytes / $byte_m; + $suffix = "m"; + }else{ + $base = $bytes / $byte_k; + $suffix = "k"; + }; + $out_string = sprintf("%.2f%s", $base, $suffix); + return $out_string; +}; + +# +# Dumb function to return if an inode has already been seen. +# So we handle hard links sane(er-ish-ly) in size calculations. +# This has more truthiness(tm). +# +sub seeninode{ + my $what = pop(); + my $ret = 0; + unless(exists($inodes{$what})){ + $inodes{$what} = 0; + print "New inode $what added to seen inodes.\n" if $debug; + }else{ + $inodes{$what}++; + $ret++; + print "Found a hardlink for $what.\n" if $debug; + }; + return $ret; +}; + +sub sieve { + my $file = $File::Find::name; + my $filedir = $File::Find::dir; + my @statinfo = lstat($file); + my $dev = $statinfo[0]; + my $inode = $statinfo[1]; + my $size = $statinfo[7]; + my $blocksize = 512; # field 11 is the "preferred" block size, which appears + # to not match the actual blocksize of the filesystems + # in use. For now every hard drive uses 512bytes/block. + # Will revisit this when 4096byte/block hard drives arrive + my $apparentsize = $statinfo[12] * $blocksize; + + print "$file\@$filedir \<$topdev\>\=\<$dev\>\n" if $debug; + print "size,apparentsize,blocksize = <$statinfo[7],$apparentsize\,$blocksize\>\n" if $debug; + # + # Try to handle sparse files. + # + if ($size > $apparentsize) { + print "Sparse file $file!\n" if $debug; + $size = $apparentsize; + }; + + $dev = (-l $file) ? 0xdeadbeef : $dev; + if (($file =~ m/\/proc|\/chroot|udev\/devices/) || + ($dev != $topdev) || seeninode($inode)){ + print "Pruned $file.\n" if $debug; + $File::Find::prune = 1; + next; + }; + unless ($dev){ + # Yay, we can't l(stat) files. This version of perl is broken. + # Snag information from ls, assume it's a file. Thanks Solaris 8, you suck. + $statbug++; + warn "Hit empty device statbug while stat()ing file <$file>.\n"; + my $ls = qx(ls -ld $file); + my @raw = split(/\s+/, $ls); + $diskhogs{"$file"} = $raw[4]; + $diskhogs{"$filedir"} += $raw[4]; + }elsif (-f){ + if ($debug){ + print "Adding $file size ", &byte_print($size), " to $filedir.\n"; + print "Adding $file size ", &byte_print($size), "\n"; + }; + $diskhogs{"$file"} = $size; + $diskhogs{"$filedir"} += $size; + }elsif (-d){ + print "Adding $file size ".&byte_print($size)."\n" if $debug; + $diskhogs{"$file"} += $size; + }; + if ($debug) { + print "$file from $filedir has size ".&byte_print($diskhogs{"$file"})."\n"; + }; +}; + +# +# Reverse sort the keys by size. +# +my @sorted = sort {$diskhogs{$b} <=> $diskhogs{$a}} keys %diskhogs; + +splice @sorted, $opt_displaynum if @sorted > $opt_displaynum; + +warn "Found one or more instances of the stat() call statbug. This is normally only present on Solaris 8 with stock perl.\n" if $statbug; + +foreach (@sorted){ + printf "%-9s%s\n", &byte_print($diskhogs{$_}), $_; +}; + +if ($debug){ + print "DEBUG INFORMATION:\n"; + foreach (keys %diskhogs){ + printf "%-9s%s\n", &byte_print($diskhogs{$_}), $_; + }; +}; +#+END_SRC +** ~/bin/ifinfo + +I don't remember now why I wrote this but its just a simpler view +of interfaces on a system. + +Probably some old solaris holdover thing I can nuke. + +Example: +$ ifinfo +gif0@1280 127.0.0.1/8 a:b:c:d:e:f +en1@1500 10.1.10.15/24 a:b:c:d:e:f +bridge100@1500 192.168.64.1/24 a:b:c:d:e:f + +Comes in slightly handy, no guarantees it parses ifconfig right tho. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/ifinfo :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Because ifconfig output is... overly verbose. +# +# Output information from ifconfig -a like so: +# interface:mtu ipv4/cidr mac_address ipv6_addr(if applicable) +# ipv6 is not yet in place due to a: lazy, b: can't use it yet. +# + +use strict; +use Socket; +use Sys::Hostname; +$ENV{'PATH'}='/sbin:/usr/sbin:/bin:/usr/bin'; + +my ($fqdn_regexp) = qr/([0-9,a-z,A-Z,\-,\_]+)\.([0-9,a-z,A-Z,\-,\_]+)\.(com|gov)/; + +# +# converts a 1-word (4 byte) signed or unsigned integer into a dotted decimal +# ip address. +# +sub int2ip { + my $n=int(pop); + return(sprintf("%d.%d.%d.%d", ($n>>24)&0xff,($n>>16)&0xff, + ($n>>8)&0xff,$n&0xff)); +}; + +# +# Convert a host/ip/netmask/cidr/etc.... to a hash of information +# Example: host.domain.tld/24 will get the ip and calculate the netmask info +# equally if host.domain.tld corresponds with 1.2.3.4 the following is valid +# 1.2.3.4/255.255.255.0 would obtain the same information. +# +# die()'s if anything isn't kosher. +# +# Ultra long function, probably needs to be looked at for condensing/splitting. +# +sub cidr2raw { + my $rawinput = pop; + my ($lhs, $rhs, $j, $uip) = (undef, undef, undef, undef); + my ($ucidr) = 0; + my ($network, $bits, $netmask, $broadcast, $low, $high); + + if ($rawinput =~ qr/(.*)\/(.*)/){ + $lhs = $1; $rhs = $2; + }else{ + die "Input: $rawinput not expected.\n"; + }; + + # + # Handle ip/hostname for left hand side. + if ($lhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ + foreach my $dotted (($1,$2,$3,$4)){ + if (($dotted > 255) or ($dotted < 0)){ + die "FATAL: ipv4 address entered, $lhs entered is impossible, $dotted is not between 0-255.\n"; + }; + }; + $uip = "$1.$2.$3.$4"; + }; + # + # Handle the netmask/cidr for the right hand side, + # + # All input netmasks are converted to a cidr address for notation + if ($rhs =~ qr/^(\d+)$/){ # /cidr + $ucidr = $1; + die "FATAL: Invalid CIDR <$ucidr>.$!\n" if (($ucidr > 32) or ($ucidr < 0)); + }elsif ($rhs =~ qr/(0[xX])?([0-9,a-f,A-F]{7})/){ # /0xhexnetmask + my $trimmed = $2; + my $insane = 0; + foreach my $byte (split('', unpack("B32", pack("H*", $trimmed)))){ + ($byte) ? $ucidr++ : $insane++; + die "FATAL: $rhs is not a valid hex netmask.$!\n" if ($insane and $byte); + }; + }elsif ($rhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ # /255.255.255.0 form + my @a = ($1, $2, $3, $4); + my $insane = 0; + foreach my $t (@a){ + die "FATAL: Netmask out of range. Input <$rhs> Invalid <$t>$!\n" if (($t < 0) or ($t > 255)); + }; + foreach my $byte (split('', unpack("B32", pack("C4", @a)))){ + ($byte) ? $ucidr++ : $insane++; + die "FATAL: $rhs is not a valid netmask.$!\n" if ($insane and $byte); + }; + }else{ + die "FATAL: Unknown or invalid netmask value entered. <$rhs>\n"; + }; + + # + # Network math GO! This is the meat of the function. + my (@uip) = split(/\./, $uip); + $network = 0; + for ($j = 0; $j <= $#uip; $j++){ + $network += int($uip[$j])<<((3-$j)*8); + }; + + $bits = 0; $j = 0; + for ($j = 31 - $ucidr; $j >= 0; $j--){ + $bits |= 1<<$j; + }; + + $netmask = 0xffffffff^$bits; + $low = ($network&$netmask); + $high = ($network&$netmask)+$bits-1; + $broadcast = ($network&$netmask)|$bits; + + # + # Throw the info back, they get a hash with zie info they may/may not need. + # All up to the caller what they want to use. + # + return ("inet4" => $uip, + "netmask" => int2ip($netmask), + "broadcast" => int2ip($broadcast), + "cidr" => $ucidr, + "router" => int2ip($low+1), + "network" => int2ip($low), + "high" => int2ip($high), + ); +}; + +my @ifout; +if ($ENV{'TESTING'} ne '') { + while(<>){ + chomp($_); + last if ($_ eq ''); + push(@ifout, $_); +# sleep 1; +# print STDERR $_ . "\n"; + } +}else{ + open IFCONFIG, "ifconfig -a |"; + @ifout = ; + close IFCONFIG; +} + +# This seems wrong but it makes parsing easier due to solaris +# non root ifconfig not displaying the mac address. Reverse the output. +# +@ifout = reverse(@ifout); + +my @output = (); + +my ($ifname, $ifether, $ifmtu, $ifipv4, $ifnetmask, $ifipv6) = (undef,undef,undef,undef,undef,undef); +sub printiface{ + # assume a /32 if we don't know it + unless (defined($ifnetmask)) { + warn "$ifname has indeterminant netmask assuming /32\n"; + $ifnetmask = '32'; + } + + unless (defined($ifnetmask)) { + $ifether = 'unknown'; + } + + unless ($ifname =~ m/lo.*/){ + my %netinfo = cidr2raw("$ifipv4\/$ifnetmask"); + $ifnetmask = $netinfo{"cidr"}; + $ifether = lc($ifether); + my $line = sprintf "%-16s %-18s %-17s\n", "$ifname\@$ifmtu", "$ifipv4\/$ifnetmask", $ifether; + push @output, $line; + } + + # reset vars + ($ifname, $ifether, $ifmtu, $ifipv4, $ifnetmask, $ifipv6) = (undef,undef,undef,undef,undef,undef); +}; + +foreach my $line (@ifout) { + if ($line =~ /inet\s+(\d+[.]\d+[.]\d+[.]\d+)\s+/){ + $ifipv4 = $1; + } + if ($line =~ m/ether\s([:,0-9,a-f,A-F]{11,})/){ + $ifether =$1; + } + if ($line =~ m/^([\w,\:\d+]+)\s+.*HWaddr\s([:,0-9,a-f,A-F]{11,})/){ + $ifname = $1; + $ifether = $2; + } + if ($line =~ m/^(.*)\:\s+.*mtu\s(\d+)/){ + $ifname = $1; + $ifmtu = $2; + } + if ($line =~ m/MTU[:](\d+)/){ + $ifmtu = $1; + } + if ($line =~ m/inet\saddr\:(\d+[.]\d+[.]\d+[.]\d+)/){ + $ifipv4 = $1; + } + if ($line =~ m/netmask\s+(0[xX])?([a-f,A-F,0-9]{8})/){ + $ifnetmask = $2; + } + if ($line =~ m/Mask[:](\d+\.\d+\.\d+\.\d+)/){ + $ifnetmask = $1; + } + if ($line =~ m/netmask\s+(\d+[.]\d+[.]\d+[.]\d+)/){ + $ifnetmask = $1; + } + if ($line =~ m/netmask\s+0\s+broadcast/){ + $ifnetmask = '0'; + } + + print ":$ifether:$ifname:$ifmtu:$ifipv4:$ifnetmask:$ifipv6:\n" if ($ENV{'DEBUG'} ne ''); + printiface() if ($ifname and $ifmtu and $ifipv4 ); +}; + +if (scalar(@output) < 1){ + warn "No interfaces? Scripts busted yo.\n"; +}else{ + foreach my $line (reverse(@output)){ + print $line; + } +} +#+END_SRC +** ~/bin/iso8601 + +Mostly because I use iso8601 timestamps and its nice to use them +generally without depending on gnu date. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/iso8601 :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +#-*-mode: Perl; coding: utf-8;-*- +use strict; +use warnings; +use POSIX qw(strftime); + +my $now = time; +my $tz = strftime(('%z', (localtime $now))); +$tz =~ s/(\d{2})(\d{2})/$1:$2/smx; +my $time = strftime('%Y-%m-%dT%H:%M:%S', (localtime $now)); +print "$time$tz\n"; +exit 0; +#+END_SRC +** ~/bin/whoson + +Basically getent passwd $username/$uid to show who is on a system. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/whoson :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Because i'm lazy and sick of typing in getent passwd $someusername/uid +# + +my %who_cmds = ("solaris", "/bin/who -q", + "linux", "/usr/bin/who -q", + "darwin", "/usr/bin/who -q", + ); + +my $who_cmd = $who_cmds{$^O}; + +local %users = (); + +foreach my $l (qx/$who_cmd/){ + next if($l =~ m/^\#.*/); + foreach my $user (split(/\s+/,$l)){ + unless(exists($users{$user})){ + $users{$user} = 0; + }else{ + $users{$user}++; + }; + }; +}; + +foreach my $user (keys %users){ + my $gecos = ( getpwnam($user) )[6]; + my $count = $users{$user} + 1; + my $output = "$user\, ".((defined($gecos)) ? "$gecos, " : '')."is logged in on $count tty".(($count>1) ? "\'s" : '')."\n"; + print $output; +}; +#+END_SRC +** ~/bin/gecos + +Silly wrapper perl script that makes it easier to get at the gecos string for a $user/$uid. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/gecos :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Dumb wrapper to get the gecos information from a uid/username. + +foreach my $input (@ARGV){ + my $gecos = undef; + my $uid = undef; + my $name = undef; + if ( $input =~ m/^\d+$/ ) { + ( $name,$uid,$gecos ) = ( getpwuid($input) )[0,2,6]; + } else { + ( $name,$uid,$gecos ) = ( getpwnam($input) )[0,2,6]; + } + print "$name is '$gecos' uid '$uid'\n" if $gecos; +} +#+END_SRC + +** ~/bin/hatimerun + +Stupid perl script to mimic hatimerun for systems that don't have it. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/hatimerun :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# hatimerun in perl, sorta +# +use Getopt::Long; + +my $opt_exitcode = 99; +my $opt_killcode = 9; +my $opt_timeout = 60; + +GetOptions( 'e=i' => \$opt_exitcode, + 'k=i' => \$opt_killcode, + 't=i' => \$opt_timeout, + 'h' => \&opt_help, + 'help' => \&opt_help, +); + +sub opt_help{ + my $message = <<__END__; +UX: ERROR: invalid syntax +usage: [-e return code][-k kill signal][-t seconds to wait] + [-h][--help] + + Options + --help, -h Prints this help text. + -e Exit code to return on timeout. + NOTE: 99 by default. + -k Signal number to send via kill. + NOTE: 9 by default. + -t Timeout in seconds before alarming. + NOTE: 60 by default. + +__END__ + print $message; + exit 1; +}; + +my $pid; + +local $SIG{ALRM} = sub { kill $opt_killcode, $pid or die "Kill failed: $!"; + die "Timeout!\n"}; + +eval{ + my $x = defined($pid = fork()); + + unless ($pid){ + print qx(@ARGV); + die "Exec of ", join(' ', @ARGV), " failed at $!\n"; + }; + + alarm $opt_timeout; + waitpid $pid => 0; + alarm 0; + exit 0; +}; + +if ($@){ + die "Nothing to do!\n" unless $@ eq "Timeout!\n"; + exit $opt_exitcode; +}else{ + exit 0; +}; +#+END_SRC + +** ~/bin/ptree.pl + +Silly perl based ptree alike implementation. Mad old code that should be avoided at all costs but it works and I'm not fixing it unless I need to. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/ptree.pl :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# ptree for linux/darwin/solaris. I got sick of ps and pstree on linux. +# ptree works on solaris fine, but doesn't exist for darwin/linux/etc... +# +# TODO: Allow passing a regexp instead of a pid and passing multiple pids. +# + +local $ENV{"PATH"} = '/bin:/usr/bin:/sbin:/usr/sbin'; +local $debug = 0; + +(exists($ENV{"DEBUG"})) ? $debug = 1 : undef; +($debug) ? local $| = 1 : undef; # disable buffering for STDERR and STDOUT + +sub debug_print { + ($debug) && warn pop; +}; + +local @cmd = ('/bin/ps'); +local $init = 0; +local $start = 1; + +if ($^O eq "linux"){ + push(@cmd, 'ajxSw'); + $start = 0; +}elsif ($^O =~ m/darwin|freebsd/){ + push(@cmd, 'Ajwww'); +}elsif ($^O eq "solaris"){ + @cmd = ('/usr/ucb/ps'); + if ((-x "/bin/zonename") && !(qx(zonename) eq "global\n")){ + $init = qx(pgrep zsched); + chomp($init); + $start = $init; + }; + push(@cmd, 'laxwww'); +}else{ + die "$^O isn't a known os to this script\n"; +}; + +local @ps = qx(@cmd); +($?) ? die $cmd[0]." posix return code $?\n" : undef; + +local %proc; +local @trail; + +(defined($ARGV[0])) ? $start = $ARGV[0] : undef; + +debug_print("Dump of raw line array data:\n"); + +foreach my $x (@ps){ + my $cmd_index = 9; + my $ppid = -1; + my $pid = -1; + next if ($x =~ m/.*PID.*/); + my @line = split(m/\s+/,$x); + splice(@line, 0, 1) unless ($line[0] =~ m/\d+/); + splice(@line, 0, 1) if ("$line[0]" eq ""); + + if ($^O eq "linux"){ + ($ppid,$pid) = @line; + $cmd_index = 9; + }elsif ($^O =~ m/darwin|freebsd/){ + ($pid,$ppid) = @line; + $cmd_index = 8; + }elsif ($^O eq "solaris"){ + (undef, undef, $pid,$ppid) = @line; + for($x=$cmd_index; $x < 14; $x++){ + $cmd_index = ($line[$x] =~ m/\d+\:\d+/) ? ($x + 1) : $cmd_index; + }; + }; + + my $command = join(' ', @line[$cmd_index..$#line++]); + (!defined $proc{$pid}) ? $proc{$pid}->{"children"} = [ ] : undef; + (!defined $proc{$ppid}) ? $proc{$ppid}->{"children"} = [ ] : undef; + $proc{$pid}->{"pid"} = $pid; + $proc{$pid}->{"command"} = $command; + $proc{$pid}->{"ppid"} = $ppid; + push(@{$proc{$ppid}->{"children"}},$pid); + debug_print(join(',', @line[0..($#line-1)])."\n"); +}; + +if ($debug){ + debug_print("Done reading ps output\nDump of Hash\n"); + foreach my $key (sort({$a <=> $b} (keys %proc))){ + $ppid = $proc{$key}->{"ppid"}; + $command = $proc{$key}->{"command"}; + $children = join(',', @{$proc{$key}->{"children"}}); + debug_print("PID<$key> PPID<$ppid> Children<$children> Command<$command>\n"); + }; +}; + +sub intrail{ + my $crumb = pop; + my $ret = 0; + map {$ret++ if ($crumb == $_)} @trail; + return $ret; +}; + +sub addchildren{ + my $start_node = pop; + foreach my $child (@{$proc{$start_node}->{"children"}}){ + next if (!defined($child) || ($start_node == $child)); + debug_print("Start ($start_node) Add child $child.\n"); + push(@trail, $child); + addchildren($child); + }; +}; + +sub addparents{ + my $start_node = pop; + my $parent = $proc{$start_node}->{"ppid"}; + return unless (defined($start_node)); + return if (($parent == $start_node) || !(defined($parent))); # At the top of the tree, or in a zone + debug_print("Start ($start_node) Add parent $parent.\n"); + push(@trail, $parent); + addparents($parent) if ($parent != $init); +}; + +sub printnode{ + my $start_node = pop; + my $indent = pop; + if (intrail($start_node)){ + my $pid = $proc{$start_node}->{"pid"}; + my $ppid = $proc{$start_node}->{"ppid"}; + my $cmdline = $proc{$start_node}->{"command"}; + my $indentation = ' 'x($indent); + if ($pid == $init){ + my $s = $^O." kernel"; + if ($cmdline ne ''){ + $s = $s." <$cmdline>"; + }; + $cmdline = $s; + }; + printf("%s%d %s\n", $indentation, $pid, $cmdline); + foreach my $child (@{$proc{$start_node}->{"children"}}){ + next if ($pid == $child); + printnode($indent+1,$child); + }; + }; +}; + +my $valid = 0; +foreach my $j (keys %proc){ ($j == $start) ? $valid++ : undef; }; + +debug_print("Starting from <$start>, validity is<$valid>\n"); + +if ($valid){ + if (!$start){ + @trail = keys %proc; + push(@trail, $start); push(@trail, 1); + debug_print("Done with adding $start to trail.\n"); + }else{ + push(@trail, $start); + debug_print("Adding children from $start.\n"); + addchildren($start); + debug_print("Adding parents from $start.\n"); + addparents($start); + }; + + @trail = sort(@trail); + + debug_print("Trail is: ".join(',', @trail)."\nStarting at pid $start\ninit pid $init\n"); + print "PID COMMAND\n"; + my $startindent = 0; + (intrail($startindent)) ? $startindent = -1 : undef; + printnode($startindent,$init); +}else{ + die "pid $start doesn't exist.\n"; +}; + +exit 0; +#+END_SRC + +** ~/bin/portchk + +Just find out if a port responds to anything tcp related or not. + +#+BEGIN_SRC perl :mkdirp yes :tangle tmp/bin/portchk :results replace :tangle-mode (identity #o755) +#!/usr/bin/env perl +# +# Dumb wrapper to get the gecos information from a uid/username. + +foreach my $input (@ARGV){ + my $gecos = undef; + my $uid = undef; + my $name = undef; + if ( $input =~ m/^\d+$/ ) { + ( $name,$uid,$gecos ) = ( getpwuid($input) )[0,2,6]; + } else { + ( $name,$uid,$gecos ) = ( getpwnam($input) )[0,2,6]; + } + print "$name is '$gecos' uid '$uid'\n" if $gecos; +} +#+END_SRC + +** ~/bin/notify + +OSX only really, just fires off a notification when its ran. + +Example: +notify "some command" "not ok" + +First param is the message, second title of the notification. + +#+BEGIN_SRC sh :mkdirp yes :tangle (when (eq osx-p t) "tmp/bin/notify") :results replace :tangle-mode (identity #o755) +#!/bin/sh +message=${1:="no message"} +title='' +if [ "${2}" != "" ]; then + message="${2}" + title="${1}" +fi +notification="display notification \"${message}\"" +[ "${title}" != "" ] && notification="${notification} with title \"${title}\"" + +osascript -e "${notification}" +#+END_SRC + +** ~/bin/today + +Stupid ruby script I wrote to highlight the week/day in a calendar. + +#+BEGIN_SRC ruby :mkdirp yes :tangle tmp/bin/today :results replace :tangle-mode (identity #o755) +#!/usr/bin/env ruby +cal, today, week_color, day_color, reset = %x(cal).split(%r(\n)), Time.now.day, %x(tput sgr0;tput setab 4;tput setaf 7), %x(tput sgr0; tput setab 0;tput setaf 7;tput bold), %x(tput sgr0) +done=false +cal.each do |line| + if done then + puts line + next + end + if(line =~ /^(.*\s+?)#{today}(\s+?.*)$/ or + line =~ /^(.*\s+?)#{today}$/ or + line =~ /^()#{today}(\s+?.*)$/ or + line =~ /^#{today}$/ ) then + puts "#{week_color}#{$1}#{day_color}#{today}#{week_color}#{$2}#{reset}" + done=true + else + puts line + end +end +#+END_SRC + +* Git +** ~/.gitconfig + +General git configuration. + +#+BEGIN_SRC conf :tangle tmp/.gitconfig :results replace +[pager] + color = true +[color] + status = auto + diff = auto + branch = auto +[color "status"] + added = green + changed = blue + untracked = red +[color "branch"] + current = green + local = blue + remote = red +[color "diff"] + meta = blue bold + frag = black reverse + old = red reverse + new = green reverse +[alias] + begin = !sh -c 'git init && git commit --allow-empty -m "Initial commit"' + up = !sh -c 'git pull --rebase && git push' + wsdiff = diff --color-words --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-all-space + wdiff = diff --color-words + ci = commit + ciu = commit --all + co = checkout + ds = diff --stat + ba = branch --all + st = status --short --branch + s = status --short --branch --untracked-files=no + unstage = reset HEAD + tlog = log --graph --color=always --abbrev-commit --date=relative --pretty=oneline + hist = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative + slog = log --oneline --decorate + fixup = commit --fixup + squash = commit --squash + ri = rebase --interactive --autosquash + ra = rebase --abort + effit = reset --hard + # What commits differ between branches, note, equivalent commits are omitted. + # Use this with three dot operator aka master...origin/master + cdiff = log --left-right --graph --cherry-pick --oneline + # Same as ^ only equivalent commits are listed with a = sign. + cmdiff = log --left-right --graph --cherry-mark --oneline +[github] + user = mitchty +[credential] + helper = netrc -v -f ~/.netrc.gpg -f ~/.netrc +[advice] + statushints = false +[gui] + fontui = -family Monaco -size 8 -weight normal -slant roman -underline 0 -overstrike 0 + fontdiff = -family Monaco -size 8 -weight normal -slant roman -underline 0 -overstrike 0 +[http] + postBuffer = 209715200 + sslcainfo = ~/.nix-profile/etc/ca-bundle.crt +[push] + default = simple +[url "https://github.com/"] + insteadOf = git://github.com/ +[user] + name = Mitch Tishmack + email = mitch.tishmack@gmail.com +#+END_SRC + +** ~/.gitignore + +Common crap/build artifacts that git should always ignore. + +#+BEGIN_SRC conf :tangle tmp/.gitignore :results replace +.*~ +*~ +.\#* +\#* +\#*\# +.\#*\# +.DS_Store +*.pyc +*.rbc +*.elc +*.swp +*.[oa] +*.hi +#+END_SRC + +* X +** ~/.Xdefaults + +X defaults, just urxvt for the moment. Slightly linux/bsd only but not really. + +#+BEGIN_SRC conf :tangle (when (eq x-p t) "tmp/.Xdefaults") :results replace +! urxvt generalish stuff +! +urxvt*termName: rxvt-256color +urxvt*font: xft:menlo:size=12:antialias=true +urxvt*perl-ext-common: default,matcher +urxvt*jumpScroll: true +urxvt*cursorColor: pink +urxvt*loginShell: true +urxvt*scrollBar: true +urxvt*scrollstyle: next +urxvt*scrollBar_right: true +urxvt*scrollTtyOutput: false +urxvt*cursorBlink: true +urxvt*saveLines: 10000 +urxvt*urlLauncher: /usr/bin/google-chrome +urxvt*matcher.button: 1 +urxvt*allowWindowOps: true +#+END_SRC + +** ~/.Xmodmap + +Swap around left/right clicks basically. + +#+BEGIN_SRC conf :tangle (when (and (eq x-p t) (not (eq osx-p t))) "tmp/.Xmodmap") +pointer = 3 2 1 4 5 +#+END_SRC + +OSX is odd. + +#+BEGIN_SRC conf :tangle (when (and (eq x-p t) (eq osx-p t)) "tmp/.Xmodmap") +pointer = 1 2 3 4 5 +#+END_SRC + +** ~/.Xresources + +I can't remember why I did all this effort. But I'll remove it some year I bet. + +#+BEGIN_SRC conf :tangle (when (eq x-p t) "tmp/.Xresources") :results replace +#define brightblack #ffffff +#define normblack #f9f9f9 +#define normgreen #00cc33 +#define brightgreen #00cc99 +#define normblue #f00033 +#define brightblue #0099ff +#define normcyan #66ccff +#define brightcyan #66ccff +#define normwhite #060606 +#define brightwhite #000000 +#define normyellow #ffcc33 +#define brightyellow #ffcc33 +#define normred #ff3300 +#define brightred #ff3300 +#define normmagenta #ff66ff +#define brightmagenta #ff66ff + +*background: normblack +*foreground: normwhite +*fading: 40 +*fadeColor: brightblack +*cursorColor: brightcyan +*pointerColorBackground: #3f3f3f +*pointerColorForeground: #f3f3f3 + +*color0: #090909 +*color1: #f00000 +*color2: normgreen +*color3: normyellow +*color4: #0066ff +*color5: normmagenta +*color6: normcyan +*color7: #c8c8c8 +*color8: #888888 +*color9: #f00033 +*color10: brightgreen +*color11: brightyellow +*color12: #0099ff +*color13: brightmagenta +*color14: brightcyan +*color15: #f9f9f9 +#+END_SRC +* Zsh +** ~/.zprofile + +Make sure that zsh sources ~/.profile correctly on login. + +#+BEGIN_SRC sh :tangle tmp/.zprofile :results replace +emulate sh +source ~/.profile +emulate zsh + +# zsh does this differently +login_shell() +{ + [[ -o login ]] +} +#+END_SRC + +** ~/.zshrc + +Zsh configuration, its not too crazy... I think. Don't judge me. + +#+BEGIN_SRC sh :tangle tmp/.zshrc :results replace +#-*-mode: Shell-script; coding: utf-8;-*- +# zsh specific global aliases +alias -g silent="> /dev/null 2>&1" +alias -g noerr="2> /dev/null" +alias -g stdboth="2>&1" + +# mainly for firefox, because it can suck up the cycles, but not when +# in a SIGSTOP state you can't use any power then firefox. +alias -g sigcont='kill -CONT ' +alias -g sigstop='kill -STOP ' + +# Keybindings, what few there are. +bindkey -v +bindkey '^P' push-line # Saves the current line and returns to it afterwards. + +# General history options +export HISTSIZE=5000 +export SAVEHIST=${HISTSIZE} +export HISTFILE=~/.zsh_history + +# I like my options +setopt append_history +setopt extended_history +setopt hist_reduce_blanks +setopt hist_no_store +setopt hist_ignore_dups +setopt histignorespace +setopt no_hist_beep +setopt no_list_beep +setopt share_history +setopt inc_append_history +setopt auto_menu +setopt bash_auto_list + +# Options that don't need to be set. +unsetopt bad_pattern # No, don't warn me on bad file patterns kthxbai. + +# The rest of the story (tm) (c) (r) in option settings. +setopt equals +setopt notify +setopt auto_cd +setopt glob_dots +setopt print_exit_value # I love you zsh for this, print out non zero exits. + +other_term() +{ + case $TERM in + *xterm*|*rxvt*|(dt|k|e)term) + print -Pn "\e]2;%~\a" + ;; + sun-cmd) + print -Pn "\e]l%~\e\\" + ;; + *) + ;; + esac +} + +chpwd() +{ + [[ -o interactive ]] || return + case $TERM in + eterm-color) # getting emacs terminal to not be annoying... sucks + print -Pn "" + ;; + *) + if [[ $SSH_TTY != '' ]]; then + case $ORIG_TERM in + eterm-color) + print -Pn "" + ;; + *) + other_term + ;; + esac + fi + ;; + esac +} + +# Needs to be reviewed a bit. +zstyle ':completion:*' squeeze-slashes true +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:*:*:*:processes' force-list always + +# No need to setup ssh known host parsing as root, just regular users. +# This is pretty old using compctl, need to update eventually. + +if [[ "$LOGNAME" != "root" ]]; then + zmodload zsh/mathfunc + if [[ -f "$HOME/.ssh/known_hosts" ]]; then + hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}) + zstyle ':completion:*:(ssh|scp|cssh):*' hosts $hosts + zstyle ':completion:*:*:*:hosts-host' ignored-patterns '|1|*' loopback localhost + fi + zstyle ':completion:::complete*' use-cache 1 + + # This really should be closer to the definition of extract. + compctl -g '*.tar.bz2 *.tbz2 *.tbz *.tar.gz *.tgz *.bz2 *.gz *.jar *.zip *.rar *.tar *.Z *.tZ *.tar.Z' + -g '*(-/)' extract +fi + +# More history options for newer zsh versions +setopt share_history +setopt hist_save_no_dups +setopt hist_find_no_dups +setopt hist_no_functions +setopt hist_expire_dups_first + +bindkey ' ' magic-space # Complete spaces too dammit, i'm lazy. + +alias edirs='ls -d **/*(/^F)' # empty directories +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:kill:*' force-list always +zstyle ':completion:*:kill:*:processes' command "ps x" +zstyle ':completion:*' menu select=2 + +autoload -U compinit +autoload -U colors && colors +autoload -Uz vcs_info + +bindkey -e + +local userat="%{$fg[blue]%}%n%(!.%{$fg[red]%}.%{$fg[blue]%})%{$reset_color%}%B@%b%{$fg[blue]%}%m%b" +local pwd="%B%~%b" +local userchar="%(!.#.$)" + +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:*' check-for-changes true +setopt prompt_subst + +precmd() +{ + vcs_info +} + +# +N/-N upstream info +function +vi-git-st() { + local ahead behind + local -a gitstatus + + ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l | sed -e 's|^ *||g') + behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l | sed -e 's|^ *||g') + + (( $ahead )) && gitstatus+=( "+${ahead}" ) + (( $behind )) && gitstatus+=( "-${behind}" ) + + hook_com[misc]+=${(j:/:)gitstatus} +} + +# Untracked crap in the repo not covered by .gitignore? +function +vi-git-untracked(){ + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ + git status --porcelain | grep '??' &> /dev/null ; then + hook_com[staged]+="%{$fg[red]%}N" + fi +} + +local branch="%{$fg[green]%}%b%c%u%{$fg[green]%}%{$reset_color%}" +zstyle ':vcs_info:*' formats "%m $branch" +zstyle ':vcs_info:*' actionformats "%a $branch" +zstyle ':vcs_info:*' stagedstr "%{$fg[blue]%}S" +zstyle ':vcs_info:*' unstagedstr "%{$fg[blue]%}M" +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st +PROMPT="%(!.#.$) " # $ as a user # as root +RPROMPT='${vcs_info_msg_0_} ${PWD/#$HOME/~}' +#+END_SRC + +* Tmux +** ~/.tmux.conf + +Tmux configuration. Pretty boring in most ways. + +#+BEGIN_SRC conf :tangle tmp/.tmux.conf :results replace +# Setup utf8 by default and vi mode +set-window-option -g utf8 on +set-window-option -g mode-keys vi +set-window-option -g aggressive-resize on + +set-option -g default-command zsh +set-option -g default-terminal 'xterm-256color' + +# Status line options, mainly coloring +set-window-option -g window-status-bg colour6 +set-window-option -g window-status-fg black +set-window-option -g window-status-current-bg white + +# Status line options +set-option -g status-bg black +set-option -g status-fg colour7 +set-option -g status-left-length 24 +set-option -g status-left '' +set-option -g status-right-length 13 +set-option -g status-right "%a %H:%M:%S" +set-option -g status-interval 7 +set-option -g status-utf8 on + +# Pane border options, mimics the status line coloring +set-option -g pane-border-bg colour15 +set-option -g pane-border-fg colour82 +set-option -g pane-active-border-bg colour15 +set-option -g pane-active-border-fg colour2 + +# Alert related things +set-option -g visual-activity on +set-option -g visual-bell on +set-option -g message-bg colour7 +set-option -g message-fg black + +# Pass through the window title and display it automatically on changes. +set-option -g set-titles on +set-option -g set-titles-string '#T' +set-window-option -g automatic-rename on + +# Key rebinding to make things more au naturalle +bind-key R \ + source-file ~/.tmux.conf \;\ + display 'reloaded tmux config' + +# Log pane output to a file, save with an iso8601 datestamp +bind-key o \ + pipe-pane -o "cat >> $HOME/tmux-`iso8601`.log" \;\ + set-window-option window-status-current-fg green \; + +bind-key O \ + pipe-pane \;\ + set-window-option window-status-current-fg default \; + +bind-key N new-session -t default + +# Using s for synchronizing panes, means that s for choosing sessions +# is now e +unbind-key s # interactive select sessions +bind-key e choose-tree + +# (un)synchronize panes with prefix-s +bind-key s \ + if-shell \ + "tmux show-window-options | grep 'synchronize-panes on'" \ + "set-window-option window-status-current-bg colour7; \ + set-window-option pane-active-border-fg colour2; \ + set-window-option pane-active-border-bg colour15; \ + set-window-option synchronize-panes off; \ + display 'synchronization off'" \ + "set-window-option window-status-current-bg red; \ + set-window-option pane-active-border-fg red; \ + set-window-option pane-active-border-bg colour15; \ + set-window-option synchronize-panes on; \ + display 'synchronizing'" + +# same thing as ^ so it sets up things if we were started with +# something else that set synchronization. +if-shell \ + "tmux show-window-options | grep 'synchronize-panes on' || /bin/true" \ + "set-window-option window-status-current-bg red; \ + set-window-option pane-active-border-fg yellow; \ + set-window-option pane-active-border-bg red" + +# Setup splits to be less annoying +bind-key \ split-window -h +bind-key - split-window -v + +# vi keybindings for pane navigation +bind-key k select-pane -U +bind-key j select-pane -D +bind-key h select-pane -L +bind-key l select-pane -R + +# Make it so that I can detach/etc while holding control down, +# PURE LAZY +bind-key C-d detach +bind-key C-n next-window +bind-key C-p previous-window + +bind-key C-k select-pane -U +bind-key C-j select-pane -D +bind-key C-h select-pane -L +bind-key C-l select-pane -R + +# Non confirming kill pane plskthxbai +bind-key x kill-pane + +# In case something I run exits straight away, i'd like to know about it. +set-option -g set-remain-on-exit on + +# Lets change the prefix key so we don't clobber emacs back one char key +unbind-key C-b + +# hacky, but C-\ isn't used by anything overly important in emacs +set-option -g prefix 'C-\' + +# two C-\'s == C-\, if i need it, likely not +bind 'C-\' send-prefix + +# Delay in sending things is dumb +set-option -s escape-time 1 + +# so we can scroll the mouse, select panes, etc... +set -g mouse on +bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'" +bind-key m \ + if-shell \ + "tmux show-options -g | grep 'mouse on'" \ + "set -g mouse off; \ + display 'Mouse modes off'" \ + "set -g mouse on; \ + display 'Mouse modes on'" + +# Assume linux for things, load osx stuff only on osx +bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer" +bind C-y run "tmux save-buffer - | xclip -i" + +# TODO: FIXME replace rainbarf with a not perl dependency magnet. +# Linux specific. Now that I installed rainbarf on things, why not use it. +# if-shell 'test "$(uname)" = "Linux"' \ +# "set-option -g status-right-length 55; \ +# set-option -g status-right '#(rainbarf --bright --width 25) %a %H:%M:%S'; " + +# osx specific +# Have to modify default command so I can ssh in. +# that and rainbarf output is 42 chars long (utf8) but helpful. +# if-shell 'test "$(uname)" = "Darwin"' \ +# "set-option -g default-command 'zsh -l'; \ +# set-option -g status-right-length 55; \ +# set-option -g status-right '#(rainbarf --remaining --bolt --bright --width 25) %a %H:%M:%S'; " +#+END_SRC +* Vim +** ~/.vimrc + +What remains of my days from being a vim user. + +#+BEGIN_SRC conf :tangle tmp/.vimrc :results replace +set nocompatible +set backspace=indent,eol,start +set history=50 " keep 50 lines of command line history +set ruler " show the cursor position all the time +set showcmd " display incomplete commands +set incsearch " do incremental searching +map Q gq +if &t_Co > 2 || has("gui_running") + syntax on + set hlsearch +endif +if has("autocmd") + filetype plugin indent on + augroup vimrcEx + au! + autocmd FileType text setlocal textwidth=78 + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | + \ endif + + augroup END +else + set autoindent " always set autoindenting on +endif " has("autocmd") +#+END_SRC + +* nix +#+BEGIN_SRC conf :mkdirp yes :tangle (when (eq nix-p t) "tmp/.nixpkgs/config.nix") +{pkgs}: { + allowUnfree = true; + allowBroken = true; + + packageOverrides = pkgs: with pkgs; { + pinentry = pkgs.pinentry.override { + gtk2 = null; + qt4 = null; + ncurses = null; + }; + gnupg = pkgs.gnupg.override { + x11Support = false; + pinentry = true; + }; + youtube-dl = pkgs.youtube-dl.override { + pandoc = null; + }; + + # haskellPackages = haskellPackages.override { + # extension = self : super : { + # cabal = pkgs.haskellPackages.cabalNoTest; + # }; + # }; + + default = with pkgs; buildEnv { + + name = "default"; + + paths = [ + ansible + ack + aria + iperf + cacert + curl + clang + clang-analyzer + diffutils + patchutils + gitAndTools.gitFull + gitAndTools.git-extras + bazaarTools + mercurial + subversionClient + gist + mercurial + docbook5 + entr + emacs + gnupg1compat + gnutar + gnumake + sloccount + cloc + less + multitail + rlwrap + gdbm + mosh + htop + imagemagick + keychain + silver-searcher + aspell + aspellDicts.en + openssl + pinentry + pbzip2 + pigz + pv + postgresql + readline + rsync + sqlite + texLiveFull + tmux + tree + wget + wakelan + unzip + upx + xz + p7zip + unrar + watch + nox + mutt + duply + zsh + pylint + python27Packages.howdoi + python27Packages.youtube-dl + python27Packages.pyflakes + python27Packages.flake8 + python27Packages.virtualenv + python27Packages.pip +# xhyve compiles normally, figure out hypervisor framework issue +# lastpass-cli no worky on osx TODO fix this it works on homebrew + ]; + }; + env_hs = + pkgs.haskell.packages.ghc7102.ghcWithPackages + (haskellPackages: with haskellPackages; [ + alex + happy + bake + cabal-dependency-licenses + cabal-install + cabal-meta + ghc-core + ghc-mod + hasktags + hindent + hoogle + hspec + idris + pandoc + shake + ShellCheck + stack + stylish-haskell + nats + transformers-compat + ] + ); + }; +} +#+END_SRC +* Language related +** Haskell +*** ~/.ghci + +Ghci setup, mostly just cosmetics. + +#+BEGIN_SRC haskell :tangle tmp/.ghci :results replace +:l ~/.ghc.hs +:set prompt "λ " +:set +t +#+END_SRC + +*** ~/.ghc.hs + +What to automatically have loaded into ghci sessions. + +#+BEGIN_SRC haskell :tangle tmp/.ghc.hs :results replace +import Control.Applicative +import Control.Monad +import Data.Monoid +import Data.Maybe +import Data.List +import Data.Bool +import qualified Data.Set as S +import qualified Data.Map as M +#+END_SRC + +** Perl +*** ~/.perlcriticrc + +What to complain about by default. + +#+BEGIN_SRC conf :tangle tmp/.perlcritirc :results replace +# Show the severity level +severity = 1 + +# Basically show what profile is complaining +verbose = %f:%l:%c: %m, %e (%p, severity %s)\n + +# Don't warn on these variables +[Variables::ProhibitPunctuationVars] +allow = $@ $! + +# Ignore syscall returns on print, it not actually returning is... whatever. +[InputOutput::RequireCheckedSyscalls] +exclude_functions = print say + +# Allow things like print qx(somecmd) in a void context to work, this is ok. +[InputOutput::ProhibitBacktickOperators] +only_in_void_context = 1 + +# I actually like using unless... so don't piss me off whinging about it +[-ControlStructures::ProhibitUnlessBlocks] + +# The following only apply to modules +[-Modules::RequireVersionVar] +[-ErrorHandling::RequireCarping] + +# Tabs suck, no +[CodeLayout::ProhibitHardTabs] +allow_leading_tabs = 0 + +# For small regexes, no /x at the end is fine, 12 should be enough +[RegularExpressions::RequireExtendedFormatting] +minimum_regex_length_to_complain_about = 12 + +# These are kosher kthxbai +[ControlStructures::ProhibitPostfixControls] +allow = for if until unless + +# For POE, we do things like my $foo = $_[HEAP]; and thats OK +[Subroutines::RequireArgUnpacking] +allow_subscripts = 1 + +# For POD documentation, I don't care about required sections. +[Documentation::RequirePodSections] +lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT | SEE ALSO +script_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR | COPYRIGHT | SEE ALSO + +# This is for POD documentation mainly. +[CodeLayout::ProhibitHardTabs] +allow_leading_tabs = 1 +#+END_SRC + +*** ~/.perltidyrc + +Control how perltidy should clean things up. + +#+BEGIN_SRC conf :tangle tmp/.perltidyrc :results replace +# cuddled elses pls +-ce +# indent 2 spaces +-i=2 +# for tokens with things like arrays, start the data next line down one indent in +-lp +# align closing tokens for things like arrays with the opening token +-cti=1 +# default, but spaces between multiple entries, none with one arg +-pt=1 +# line encoding +-ole=unix +# braces not on new line +-nsbl +# stack opening tokens, don't create a new line with one token, note no stacking of closing tokens +-sot +# no space before ;'s in for loops +-nsfs +# Make curly braces act more like the args param +-bbt=1 +# Trim qw whitespaces +-tqw +#+END_SRC + +* Misc + +Stuff that logically doesn't fit elsewhere or in any other category. + +** ~/.dir_colors + +For BSD ps, make colors closer to what the GNU utilities produce by default. + +#+BEGIN_SRC conf :tangle tmp/.dir_colors :results replace +COLOR tty + +TERM ansi +TERM color-xterm +TERM con132x25 +TERM con132x30 +TERM con132x43 +TERM con132x60 +TERM con80x25 +TERM con80x28 +TERM con80x30 +TERM con80x43 +TERM con80x50 +TERM con80x60 +TERM cons25 +TERM console +TERM cygwin +TERM dtterm +TERM eterm-color +TERM Eterm +TERM gnome +TERM konsole +TERM kterm +TERM linux +TERM linux-c +TERM mach-color +TERM putty +TERM rxvt +TERM rxvt-cygwin +TERM rxvt-cygwin-native +TERM rxvt-unicode +TERM screen +TERM screen-bce +TERM screen-w +TERM screen.linux +TERM vt100 +TERM xterm +TERM xterm-256color +TERM xterm-color +TERM xterm-debian + +# Below are the color init strings for the basic file types. A color init +# string consists of one or more of the following numeric codes: +# Attribute codes: +# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed +# Text color codes: +# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white +# Background color codes: +# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white +NORMAL 00 # global default, although everything should be something. +FILE 00 # normal file +DIR 01;34 # directory +LINK 01;36 # symbolic link. (If you set this to 'target' instead of a + # numerical value, the color will match the file pointed to) +FIFO 40;33 # pipe +SOCK 01;35 # socket +DOOR 01;35 # door +BLK 40;33;01 # block device driver +CHR 40;33;01 # character device driver +ORPHAN 01;05;37;41 # orphaned syminks +MISSING 01;05;37;41 # ... and the files they point to + +# This is for files with execute permission: +EXEC 01;32 + +# List any file extensions like '.gz' or '.tar' that you would like ls +# to colorize below. Put the extension, a space, and the color init string. +# (and any comments you want to add after a '#') + +.cmd 01;32 # executables (bright green) +.exe 01;32 +.com 01;32 +.btm 01;32 +.bat 01;32 +.sh 01;32 +.csh 01;32 +.ksh 01;32 +.zsh 01;32 + +.tar 01;31 # archives / compressed (bright red) +.tgz 01;31 +.arj 01;31 +.taz 01;31 +.lzh 01;31 +.zip 01;31 +.z 01;31 +.Z 01;31 +.gz 01;31 +.bz2 01;31 +.bz 01;31 +.tbz2 01;31 +.tz 01;31 +.deb 01;31 +.rpm 01;31 +.rar 01;31 # app-arch/rar +.ace 01;31 # app-arch/unace +.zoo 01;31 # app-arch/zoo +.cpio 01;31 # app-arch/cpio +.7z 01;31 # app-arch/p7zip +.rz 01;31 # app-arch/rzip +#+END_SRC + +** ~/.hushlogin + +Because who gives a rats when and where I last logged on from? + +#+BEGIN_SRC conf :tangle tmp/.hushlogin :results replace +#+END_SRC + + +* Reference for babel stuff + +Found this STUPID useful for constructing the tangle stuff. + +[[https://raw.githubusercontent.com/eschulte/babel-dev/master/scraps.org][babel scraps link]] diff --git a/tmux/.profile.d/20-functions-tmux.sh b/tmux/.profile.d/20-functions-tmux.sh deleted file mode 100644 index 81f27be..0000000 --- a/tmux/.profile.d/20-functions-tmux.sh +++ /dev/null @@ -1,11 +0,0 @@ -# tmux/.profile.d/20-functions-tmux.sh -t() -{ - if [ -z "$1" ]; then - echo "Supply a tmux session name to connect to/create" - else - tmux has-session -t "$1" 2>/dev/null - [ $? != 0 ] && tmux new-session -d -s "$1" - tmux attach-session -d -t "$1" - fi -} diff --git a/tmux/.profile.d/99-alias-tmux.sh b/tmux/.profile.d/99-alias-tmux.sh deleted file mode 100644 index 91d024f..0000000 --- a/tmux/.profile.d/99-alias-tmux.sh +++ /dev/null @@ -1,2 +0,0 @@ -# tmux/.profile.d/99-alias-tmux.sh -alias tl='tmux ls' diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf deleted file mode 100644 index b7e706c..0000000 --- a/tmux/.tmux.conf +++ /dev/null @@ -1,151 +0,0 @@ -# Setup utf8 by default and vi mode -set-window-option -g utf8 on -set-window-option -g mode-keys vi -set-window-option -g aggressive-resize on - -set-option -g default-command zsh -set-option -g default-terminal 'xterm-256color' - -# Status line options, mainly coloring -set-window-option -g window-status-bg colour6 -set-window-option -g window-status-fg black -set-window-option -g window-status-current-bg white - -# Status line options -set-option -g status-bg black -set-option -g status-fg colour7 -set-option -g status-left-length 24 -set-option -g status-left '' -set-option -g status-right-length 13 -set-option -g status-right "%a %H:%M:%S" -set-option -g status-interval 7 -set-option -g status-utf8 on - -# Pane border options, mimics the status line coloring -set-option -g pane-border-bg colour15 -set-option -g pane-border-fg colour82 -set-option -g pane-active-border-bg colour15 -set-option -g pane-active-border-fg colour2 - -# Alert related things -set-option -g visual-activity on -set-option -g visual-bell on -set-option -g message-bg colour7 -set-option -g message-fg black - -# Pass through the window title and display it automatically on changes. -set-option -g set-titles on -set-option -g set-titles-string '#T' -set-window-option -g automatic-rename on - -# Key rebinding to make things more au naturalle -bind-key R \ - source-file ~/.tmux.conf \;\ - display 'reloaded tmux config' - -# Log pane output to a file, save with an iso8601 datestamp -bind-key o \ - pipe-pane -o "cat >> $HOME/tmux-`iso8601`.log" \;\ - set-window-option window-status-current-fg green \; - -bind-key O \ - pipe-pane \;\ - set-window-option window-status-current-fg default \; - -bind-key N new-session -t default - -# Using s for synchronizing panes, means that s for choosing sessions -# is now e -unbind-key s # interactive select sessions -bind-key e choose-tree - -# (un)synchronize panes with prefix-s -bind-key s \ - if-shell \ - "tmux show-window-options | grep 'synchronize-panes on'" \ - "set-window-option window-status-current-bg colour7; \ - set-window-option pane-active-border-fg colour2; \ - set-window-option pane-active-border-bg colour15; \ - set-window-option synchronize-panes off; \ - display 'synchronization off'" \ - "set-window-option window-status-current-bg red; \ - set-window-option pane-active-border-fg red; \ - set-window-option pane-active-border-bg colour15; \ - set-window-option synchronize-panes on; \ - display 'synchronizing'" - -# same thing as ^ so it sets up things if we were started with -# something else that set synchronization. -if-shell \ - "tmux show-window-options | grep 'synchronize-panes on' || /bin/true" \ - "set-window-option window-status-current-bg red; \ - set-window-option pane-active-border-fg yellow; \ - set-window-option pane-active-border-bg red" - -# Setup splits to be less annoying -bind-key \ split-window -h -bind-key - split-window -v - -# vi keybindings for pane navigation -bind-key k select-pane -U -bind-key j select-pane -D -bind-key h select-pane -L -bind-key l select-pane -R - -# Make it so that I can detach/etc while holding control down, -# PURE LAZY -bind-key C-d detach -bind-key C-n next-window -bind-key C-p previous-window - -bind-key C-k select-pane -U -bind-key C-j select-pane -D -bind-key C-h select-pane -L -bind-key C-l select-pane -R - -# Non confirming kill pane plskthxbai -bind-key x kill-pane - -# In case something I run exits straight away, i'd like to know about it. -set-option -g set-remain-on-exit on - -# Lets change the prefix key so we don't clobber emacs back one char key -unbind-key C-b - -# hacky, but C-\ isn't used by anything overly important in emacs -set-option -g prefix 'C-\' - -# two C-\'s == C-\, if i need it, likely not -bind 'C-\' send-prefix - -# Delay in sending things is dumb -set-option -s escape-time 1 - -# so we can scroll the mouse, select panes, etc... -set -g mouse on -bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'" -bind-key m \ - if-shell \ - "tmux show-options -g | grep 'mouse on'" \ - "set -g mouse off; \ - display 'Mouse modes off'" \ - "set -g mouse on; \ - display 'Mouse modes on'" - -# Assume linux for things, load osx stuff only on osx -bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer" -bind C-y run "tmux save-buffer - | xclip -i" - -# TODO: FIXME replace rainbarf with a not perl dependency magnet. -# Linux specific. Now that I installed rainbarf on things, why not use it. -# if-shell 'test "$(uname)" = "Linux"' \ -# "set-option -g status-right-length 55; \ -# set-option -g status-right '#(rainbarf --bright --width 25) %a %H:%M:%S'; " - -# osx specific -# Have to modify default command so I can ssh in. -# that and rainbarf output is 42 chars long (utf8) but helpful. -# if-shell 'test "$(uname)" = "Darwin"' \ -# "set-option -g default-command 'zsh -l'; \ -# set-option -g status-right-length 55; \ -# set-option -g status-right '#(rainbarf --remaining --bolt --bright --width 25) %a %H:%M:%S'; " diff --git a/vim/.vimrc b/vim/.vimrc deleted file mode 100644 index 054681a..0000000 --- a/vim/.vimrc +++ /dev/null @@ -1,25 +0,0 @@ -set nocompatible -set backspace=indent,eol,start -set history=50 " keep 50 lines of command line history -set ruler " show the cursor position all the time -set showcmd " display incomplete commands -set incsearch " do incremental searching -map Q gq -if &t_Co > 2 || has("gui_running") - syntax on - set hlsearch -endif -if has("autocmd") - filetype plugin indent on - augroup vimrcEx - au! - autocmd FileType text setlocal textwidth=78 - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | - \ endif - - augroup END -else - set autoindent " always set autoindenting on -endif " has("autocmd") diff --git a/x/.Xdefaults b/x/.Xdefaults deleted file mode 100644 index 4773eef..0000000 --- a/x/.Xdefaults +++ /dev/null @@ -1,17 +0,0 @@ -! urxvt generalish stuff -! -urxvt*termName: rxvt-256color -urxvt*font: xft:menlo:size=12:antialias=true -urxvt*perl-ext-common: default,matcher -urxvt*jumpScroll: true -urxvt*cursorColor: pink -urxvt*loginShell: true -urxvt*scrollBar: true -urxvt*scrollstyle: next -urxvt*scrollBar_right: true -urxvt*scrollTtyOutput: false -urxvt*cursorBlink: true -urxvt*saveLines: 10000 -urxvt*urlLauncher: /usr/bin/google-chrome -urxvt*matcher.button: 1 -urxvt*allowWindowOps: true diff --git a/x/.Xmodmap b/x/.Xmodmap deleted file mode 100644 index 2153f8b..0000000 --- a/x/.Xmodmap +++ /dev/null @@ -1 +0,0 @@ -pointer = 3 2 1 4 5 diff --git a/x/.Xresources b/x/.Xresources deleted file mode 100644 index ffb58ee..0000000 --- a/x/.Xresources +++ /dev/null @@ -1,41 +0,0 @@ -#define brightblack #ffffff -#define normblack #f9f9f9 -#define normgreen #00cc33 -#define brightgreen #00cc99 -#define normblue #f00033 -#define brightblue #0099ff -#define normcyan #66ccff -#define brightcyan #66ccff -#define normwhite #060606 -#define brightwhite #000000 -#define normyellow #ffcc33 -#define brightyellow #ffcc33 -#define normred #ff3300 -#define brightred #ff3300 -#define normmagenta #ff66ff -#define brightmagenta #ff66ff - -*background: normblack -*foreground: normwhite -*fading: 40 -*fadeColor: brightblack -*cursorColor: brightcyan -*pointerColorBackground: #3f3f3f -*pointerColorForeground: #f3f3f3 - -*color0: #090909 -*color1: #f00000 -*color2: normgreen -*color3: normyellow -*color4: #0066ff -*color5: normmagenta -*color6: normcyan -*color7: #c8c8c8 -*color8: #888888 -*color9: #f00033 -*color10: brightgreen -*color11: brightyellow -*color12: #0099ff -*color13: brightmagenta -*color14: brightcyan -*color15: #f9f9f9 diff --git a/x/.profile.d/11-x-modmap.sh b/x/.profile.d/11-x-modmap.sh deleted file mode 100644 index 1baa1a0..0000000 --- a/x/.profile.d/11-x-modmap.sh +++ /dev/null @@ -1,6 +0,0 @@ -# x/.profile.d/11-x-modmap.sh -# x/.profile.d/11-x-modmap.sh -modmap -{ - [ -f "${HOME}/.Xmodmap" ] && xmodmap "${HOME}/.Xmodmap" -} diff --git a/zsh/.zprofile b/zsh/.zprofile deleted file mode 100644 index f348144..0000000 --- a/zsh/.zprofile +++ /dev/null @@ -1,9 +0,0 @@ -emulate sh -source ~/.profile -emulate zsh - -# zsh does this differently -login_shell() -{ - [[ -o login ]] -} diff --git a/zsh/.zshrc b/zsh/.zshrc deleted file mode 100644 index 05add55..0000000 --- a/zsh/.zshrc +++ /dev/null @@ -1,166 +0,0 @@ -#-*-mode: Shell-script; coding: utf-8;-*- -# zsh specific global aliases -alias -g silent="> /dev/null 2>&1" -alias -g noerr="2> /dev/null" -alias -g stdboth="2>&1" - -# mainly for firefox, because it can suck up the cycles, but not when -# in a SIGSTOP state you can't use any power then firefox. -alias -g sigcont='kill -CONT ' -alias -g sigstop='kill -STOP ' - -# Keybindings, what few there are. -bindkey -v -bindkey '^P' push-line # Saves the current line and returns to it afterwards. - -# General history options -export HISTSIZE=5000 -export SAVEHIST=${HISTSIZE} -export HISTFILE=~/.zsh_history - -# I like my options -setopt append_history -setopt extended_history -setopt hist_reduce_blanks -setopt hist_no_store -setopt hist_ignore_dups -setopt histignorespace -setopt no_hist_beep -setopt no_list_beep -setopt share_history -setopt inc_append_history -setopt auto_menu -setopt bash_auto_list - -# Options that don't need to be set. -unsetopt bad_pattern # No, don't warn me on bad file patterns kthxbai. - -# The rest of the story (tm) (c) (r) in option settings. -setopt equals -setopt notify -setopt auto_cd -setopt glob_dots -setopt print_exit_value # I love you zsh for this, print out non zero exits. - -other_term() -{ - case $TERM in - *xterm*|*rxvt*|(dt|k|e)term) - print -Pn "\e]2;%~\a" - ;; - sun-cmd) - print -Pn "\e]l%~\e\\" - ;; - *) - ;; - esac -} - -chpwd() -{ - [[ -o interactive ]] || return - case $TERM in - eterm-color) # getting emacs terminal to not be annoying... sucks - print -Pn "" - ;; - *) - if [[ $SSH_TTY != '' ]]; then - case $ORIG_TERM in - eterm-color) - print -Pn "" - ;; - *) - other_term - ;; - esac - fi - ;; - esac -} - -# Needs to be reviewed a bit. -zstyle ':completion:*' squeeze-slashes true -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' -zstyle ':completion:*:*:*:*:processes' force-list always - -# No need to setup ssh known host parsing as root, just regular users. -# This is pretty old using compctl, need to update eventually. - -if [[ "$LOGNAME" != "root" ]]; then - zmodload zsh/mathfunc - if [[ -f "$HOME/.ssh/known_hosts" ]]; then - hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*}) - zstyle ':completion:*:(ssh|scp|cssh):*' hosts $hosts - zstyle ':completion:*:*:*:hosts-host' ignored-patterns '|1|*' loopback localhost - fi - zstyle ':completion:::complete*' use-cache 1 - - # This really should be closer to the definition of extract. - compctl -g '*.tar.bz2 *.tbz2 *.tbz *.tar.gz *.tgz *.bz2 *.gz *.jar *.zip *.rar *.tar *.Z *.tZ *.tar.Z' + -g '*(-/)' extract -fi - -# More history options for newer zsh versions -setopt share_history -setopt hist_save_no_dups -setopt hist_find_no_dups -setopt hist_no_functions -setopt hist_expire_dups_first - -bindkey ' ' magic-space # Complete spaces too dammit, i'm lazy. - -alias edirs='ls -d **/*(/^F)' # empty directories -zstyle ':completion:*:*:kill:*' menu yes select -zstyle ':completion:*:kill:*' force-list always -zstyle ':completion:*:kill:*:processes' command "ps x" -zstyle ':completion:*' menu select=2 - -autoload -U compinit -autoload -U colors && colors -autoload -Uz vcs_info - -bindkey -e - -local userat="%{$fg[blue]%}%n%(!.%{$fg[red]%}.%{$fg[blue]%})%{$reset_color%}%B@%b%{$fg[blue]%}%m%b" -local pwd="%B%~%b" -local userchar="%(!.#.$)" - -zstyle ':vcs_info:*' enable git -zstyle ':vcs_info:*' check-for-changes true -setopt prompt_subst - -precmd() -{ - vcs_info -} - -# +N/-N upstream info -function +vi-git-st() { - local ahead behind - local -a gitstatus - - ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l | sed -e 's|^ *||g') - behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l | sed -e 's|^ *||g') - - (( $ahead )) && gitstatus+=( "+${ahead}" ) - (( $behind )) && gitstatus+=( "-${behind}" ) - - hook_com[misc]+=${(j:/:)gitstatus} -} - -# Untracked crap in the repo not covered by .gitignore? -function +vi-git-untracked(){ - if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ - git status --porcelain | grep '??' &> /dev/null ; then - hook_com[staged]+="%{$fg[red]%}N" - fi -} - -local branch="%{$fg[green]%}%b%c%u%{$fg[green]%}%{$reset_color%}" -zstyle ':vcs_info:*' formats "%m $branch" -zstyle ':vcs_info:*' actionformats "%a $branch" -zstyle ':vcs_info:*' stagedstr "%{$fg[blue]%}S" -zstyle ':vcs_info:*' unstagedstr "%{$fg[blue]%}M" -zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st -PROMPT="%(!.#.$) " # $ as a user # as root -RPROMPT='${vcs_info_msg_0_} ${PWD/#$HOME/~}'