Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonk committed Jun 22, 2011
1 parent 1981748 commit b5afe40
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 52 deletions.
50 changes: 29 additions & 21 deletions .bashrc
Expand Up @@ -3,29 +3,37 @@
# Source global definitions
if [ -f /etc/bashrc ]; then . /etc/bashrc; fi

. $HOME/.bashrc.d/lib/pathedit.sh

pathedit() {
eval `patheditor PATH "$@"`
}
manpathedit() {
eval `patheditor MANPATH "$@"`
}
perl5libedit() {
eval `patheditor PERL5LIB "$@"`
}
fignoreedit() {
eval `patheditor FIGNORE "$@"`
}
cdpathedit() {
eval `patheditor CDPATH "$@"`
function source_scripts() {
local script
local dir
for dir in "$@"; do
pushd $dir > /dev/null || break
for script in *.sh; do
if [ -f "$script" ]; then
. "$script"
fi
done
popd > /dev/null || break
done
}

source_scripts $HOME/.bashrc.d/lib

pathedit --prepend ~/bin ~/tools/bin /usr/local/bin
manpathedit --prepend /usr/local/share/man

source_scripts $HOME/.bashrc.d

pathedit --clean-duplicates
manpathedit --clean-duplicates
cdpathedit --clean-duplicates
perl5libedit --clean-duplicates

for i in $HOME/.bashrc.d/*.sh; do if [ -f "$i" ]; then . $i; fi; done

pathedit --cleanup
manpathedit --cleanup
cdpathedit --cleanup
perl5libedit --cleanup
#if [ "$TERM_PROGRAM" = "Apple_Terminal" ]; then
# function ssh {
# SetTerminalStyle ssh
# /usr/bin/ssh "$@"
# SetTerminalStyle default
# }
#fi
1 change: 1 addition & 0 deletions .bashrc.d/environment.sh
Expand Up @@ -11,6 +11,7 @@ export HISTSIZE=1000
pathedit --prepend $HOME/bin
pathedit --append /usr/local/bin /usr/local/sbin /opt/local/bin /opt/local/sbin /usr/sbin /sbin
manpathedit --append /usr/local/man /opt/local/share/man /usr/share/man
pathedit --append $HOME/.gem/ruby/1.8/bin
unset MAILCHECK
export LANG=C
export TZ=EST5EDT
Expand Down
38 changes: 38 additions & 0 deletions .bashrc.d/lib/pathedit.sh
@@ -1,5 +1,24 @@
#!/bin/sh

patheditor_clean_duplicates() {
local saw=":"
local nb=${#new[*]}
local i=0
for (( i = 0 ; i < nb ; i++ )) do
local x=${new[$i]}
if [[ $saw =~ ":$x:" ]]; then unset new[$i]; fi
saw="$saw:$x"
done
}
patheditor_clean_missing() {
local nb=${#new[*]}
local i=0
for (( i = 0 ; i < nb ; i++ )) do
local x=${new[$i]}
if [[ ! -d $x ]]; then unset new[$i]; fi
done
}

function patheditor() {
local var=$1; shift;
local act=$1; shift;
Expand Down Expand Up @@ -59,6 +78,9 @@ function patheditor() {
fi
new=( ${newerlist[@]} )
;;
--clean-duplicates) patheditor_clean_duplicates ;;
--clean-missing)
;;
--cleanup)
local saw=":"
local nb=${#new[*]}
Expand All @@ -79,3 +101,19 @@ function patheditor() {
echo "export $var=\"${new[*]}\""
IFS=$oldifs
}

pathedit() {
eval `patheditor PATH "$@"`
}
manpathedit() {
eval `patheditor MANPATH "$@"`
}
perl5libedit() {
eval `patheditor PERL5LIB "$@"`
}
fignoreedit() {
eval `patheditor FIGNORE "$@"`
}
cdpathedit() {
eval `patheditor CDPATH "$@"`
}
2 changes: 1 addition & 1 deletion .bashrc.d/perl.sh
@@ -1,2 +1,2 @@
pathedit --prepend "/opt/perl-5.10.1/bin"
pathedit --prepend "/opt/perl-5.12.3/bin"
perl5libedit --prepend "$HOME/lib"
94 changes: 94 additions & 0 deletions .dir_colors
@@ -0,0 +1,94 @@
# Configuration file for the color ls utility
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR tty

# Extra command line options for ls go here.
# Basically these ones are:
# -F = show '/' for dirs, '*' for executables, etc.
# -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM xterm
TERM rxvt
TERM xterm-color
TERM color-xterm
TERM vt100
TERM dtterm
TERM color_xterm

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1

# 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
FIFO 40;33 # pipe
SOCK 01;35 # socket
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
.tar 01;31 # archives or 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
.tz 01;31
.rpm 01;31
.cpio 01;31
.jpg 01;35 # image formats
.gif 01;35
.bmp 01;35
.xbm 01;35
.xpm 01;35
.png 01;35
.tif 01;35
4 changes: 1 addition & 3 deletions .vim/perl-support/templates/perl-module-header
@@ -1,9 +1,7 @@
package |PACKAGE|;
use strict; use warnings;
our $VERSION = '0.01';
our $AUTHORITY = 'cpan:JASONK';
use Moose;
use namespace::clean -except => 'meta';
use namespace::autoclean;

__PACKAGE__->meta->make_immutable;
1;
14 changes: 0 additions & 14 deletions Makefile

This file was deleted.

9 changes: 9 additions & 0 deletions config.txt
@@ -0,0 +1,9 @@
.bashrc
.bashrc.d delete
.dir_colors
.gitconfig
.perlcriticrc
.profile
.vim delete
.vimrc
bin
89 changes: 76 additions & 13 deletions dotfiles
Expand Up @@ -4,26 +4,74 @@ use FindBin qw( $Bin );

chdir( $Bin ) || die "chdir( $Bin ): $!";

my $cmd = shift || usage();

chomp( my @tops = `ls -1a` );
my %config = read_config();

@tops = grep { ! (
/^(Makefile|README|dotfiles|\.\.?|\.git)$/ || /\.(old|tmp)$/
) } @tops;
my $cmd = shift || usage();

if ( $cmd eq 'diff' ) {
foreach_file( sub { system( 'diff', '-buN', $_, "$ENV{ 'HOME' }/$_" ) } );
#foreach_file( sub { diff( $_, "$ENV{ 'HOME' }/$_" ) } );
} elsif ( $cmd eq 'summary' ) {
foreach_file( sub { system( 'diff', '-buNq', $_, "$ENV{ 'HOME' }/$_" ) } );
#foreach_file( sub { diff( '-q', $_, "$ENV{ 'HOME' }/$_" ) } );
} elsif ( $cmd eq 'pull' ) {
foreach_file( sub { system( 'cp', "$ENV{ 'HOME' }/$_", $_ ) } );
if ( @ARGV ) {
pull_from( $_ ) for @ARGV;
} else {
pull_from( $ENV{ 'HOME' } );
}
} elsif ( $cmd eq 'push' ) {
system( 'rsync', '-avP', @tops, $ENV{ 'HOME' } );
if ( @ARGV ) {
push_to( $_ ) for @ARGV;
} else {
push_to( $ENV{ 'HOME' } );
}
} else {
usage();
}

sub diff {
system( 'diff', '-buNP', @_ );
}

sub rsync {
system( 'rsync', '-avPH', @_ ) == 0 or die "rsync failed\n";
}
#sub pull_from {
# my $src = shift;
# rsync( $src.'{'.join(',', @tops ).'}', '.' );
#}

sub pull_from {
my $src = shift;
my %argmap = (
delete => '--delete',
);
for my $key ( keys %config ) {
my @args = ();
for my $arg ( @{ $config{ $key } } ) {
if ( $argmap{ $arg } ) {
push( @args, $argmap{ $arg } );
}
}
rsync( @args, $src, $key );
}
}

sub push_to {
my $dest = shift;
my %argmap = (
delete => '--delete',
);
for my $key ( keys %config ) {
my @args = ();
for my $arg ( @{ $config{ $key } } ) {
if ( $argmap{ $arg } ) {
push( @args, $argmap{ $arg } );
}
}
rsync( @args, $key, $dest );
}
}

sub foreach_file {
my $code = shift;
for my $file ( all_files() ) {
Expand All @@ -32,9 +80,23 @@ sub foreach_file {
}
}

sub all_files {
chomp( my @files = `find @tops -type f` );
return @files;
#sub all_files {
# chomp( my @files = `find @tops -type f` );
# return @files;
#}

sub read_config {
my %config = ();
open( my $fh, 'config.txt' ) or die "can't read config.txt: $!";
while ( local $_ = <$fh> ) {
chomp;
s/#.*//;
s/^\s*|\s*$//g;
next unless length( $_ );
my ( $path, @options ) = split;
$config{ $path } = \@options;
}
return %config;
}

sub usage {
Expand All @@ -45,6 +107,7 @@ Commands:
diff Show differences between repo and system
pull Pull changes from system into repo
push Push changes from repo onto system
commit Commit changes to github repo
update Pull updates from github repo
Expand Down

0 comments on commit b5afe40

Please sign in to comment.