summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore48
-rw-r--r--Makefile46
-rw-r--r--bash_login1
-rw-r--r--bash_logout3
-rw-r--r--bashrc73
-rwxr-xr-xbin/batchssh3
-rwxr-xr-xbin/git-blame-from-line-number23
-rwxr-xr-xbin/git-blame-stats37
-rwxr-xr-xbin/show-colors63
-rwxr-xr-xbin/sync-shell-files15
-rwxr-xr-xbin/tgz12
-rw-r--r--gitconfig33
-rw-r--r--gitignore10
-rw-r--r--tmux.conf29
-rw-r--r--vimrc55
15 files changed, 451 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..55cfc24
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,48 @@
+*.elc
+/config/systemd/user/*.wants
+/ssh/
+!/ssh/authorized_keys
+bin/fixssh
+.DS_Store
+.build/*
+env/*
+*.pyc
+.metadata
+.project
+.pydevproject
+*.egg-info/
+.idea/
+gephi-cli.iml
+target/
+.arc
+.lein-failures
+.lein-plugins/
+*.war
+todo.org
+release-*.txt
+nosetests.xml
+*.db
+checkouts/
+.vim/fuf-data/
+vim/.netrwhist
+emacsclient
+.ideax
+.bash/local
+tramp
+url/
+emacs.el
+/emacs.d/elpa/
+personal/rcirc
+personal/savefile
+personal/password.el.gpg
+ac-comphist.dat
+eshell/
+/.cask
+projectile-bookmarks.eld
+projectile.cache
+savefile/
+auto-save-list
+recentf
+var/
+bookmarks
+custom-set-variables
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..dc4aaef
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,46 @@
+INTO    = $(HOME)
+
+INSTALL = \
+	  bash_login \
+	  bash_logout \
+	  bashrc \
+	  bin \
+	  gitconfig \
+	  gitignore \
+	  tmux.conf \
+	  vimrc
+
+git:
+	git config --local user.email "franck@lumberjaph.net"
+	git config --local user.name "Franck Cuny"
+
+INSTALLED = $(patsubst %,$(INTO)/.%,$(INSTALL))
+LN        = @ln -sf
+
+install: $(INSTALLED) $(HOME)/bin $(HOME)/src $(HOME)/tmp $(HOME)/.ssh/authorized_keys git
+
+$(INTO)/.% : %
+	@[ ! -e $@ ] || [ -h $@ ] || mv -f $@ $@.bak
+	$(LN) $(PWD)/$< $@
+
+$(HOME)/.ssh/authorized_keys:
+	$(LN) $(PWD)/ssh/authorized_keys $(HOME)/.ssh/authorized_keys
+
+$(HOME)/bin:
+	mkdir -p $(HOME)/bin
+
+$(HOME)/src:
+	mkdir -p $(HOME)/src
+
+$(HOME)/tmp:
+	mkdir -p $(HOME)/tmp
+
+check-dead:
+	@find ~ -maxdepth 1 -name '.*' -type l -exec test ! -e {} \; -print
+	@find ~/bin -maxdepth 1 -name '.*' -type l -exec test ! -e {} \; -print
+
+clean-dead:
+	@find ~ -maxdepth 1 -name '.*' -type l -exec test ! -e {} \; -delete
+	@find ~/bin -maxdepth 1 -name '.*' -type l -exec test ! -e {} \; -delete
+
+.PHONY: install check-dead clean-dead git
diff --git a/bash_login b/bash_login
new file mode 100644
index 0000000..4b18bd1
--- /dev/null
+++ b/bash_login
@@ -0,0 +1 @@
+source $HOME/.bashrc
diff --git a/bash_logout b/bash_logout
new file mode 100644
index 0000000..3aa4f01
--- /dev/null
+++ b/bash_logout
@@ -0,0 +1,3 @@
+sudo -k
+clear
+
diff --git a/bashrc b/bashrc
new file mode 100644
index 0000000..751f5e1
--- /dev/null
+++ b/bashrc
@@ -0,0 +1,73 @@
+export EDITOR="vim"
+export HISTFILE=
+export LANG="en_US.UTF-8"
+export LC_ALL="$LANG"
+export LC_CTYPE="$LANG"
+export PAGER="less"
+export TMPDIR="${HOME}/tmp"
+export TZ=America/Los_Angeles
+
+export PATH="$HOME/bin":"$HOME/.bin":"$PATH"
+
+[ -z "$PS1" ] && return
+
+# prompts
+export PS1="\w % "
+
+# limits
+ulimit -S -c 0
+
+# Set up ssh-agent
+SSH_ENV="$HOME/.ssh/environment"
+
+function start_agent {
+  if [[ -f "${HOME}/.ssh/id_rsa" ]]; then
+    echo "Initializing new GPG agent..."
+    touch $SSH_ENV
+    chmod 600 "${SSH_ENV}"
+    /usr/bin/ssh-agent | sed 's/^echo/#echo/' >> "${SSH_ENV}"
+    . "${SSH_ENV}" > /dev/null
+    /usr/bin/ssh-add
+  fi
+}
+
+# Source SSH settings, if applicable
+if [ -f "${SSH_ENV}" ]; then
+  . "${SSH_ENV}" > /dev/null
+  kill -0 $SSH_AGENT_PID 2>/dev/null || {
+    start_agent
+  }
+else
+  start_agent
+fi
+
+# some aliases
+if [[ "${OSTYPE}" =~ "darwin" ]]; then
+  alias ls='ls -G'
+else
+  alias ls='ls --color'
+fi
+
+alias cp="cp -i"
+alias l="ls"
+alias la="ls -a"
+alias ll="ls -lh"
+alias lt="ls -lhtr"
+alias mv="mv -i"
+alias rm="rm -i"
+
+alias e="$EDITOR"
+alias g="git"
+alias gclean="git clean -dfx"
+
+alias gerp="grep --color=auto"
+alias grep="grep --color=auto"
+
+alias pjson="python -mjson.tool"
+
+# tmux
+alias tmux='tmux -2'
+alias main='tmux a -t main'
+alias work='tmux new-session -A -s work'
+
+[ -f "${HOME}/.bash_local" ] && source "${HOME}/.bash_local"
diff --git a/bin/batchssh b/bin/batchssh
new file mode 100755
index 0000000..e60da7d
--- /dev/null
+++ b/bin/batchssh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=2 "$@"
diff --git a/bin/git-blame-from-line-number b/bin/git-blame-from-line-number
new file mode 100755
index 0000000..dbe1970
--- /dev/null
+++ b/bin/git-blame-from-line-number
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+usage() {
+  echo "usage: $0 <filename> <lineno>"
+  exit 1
+}
+
+filename="$1"
+
+[ -z "${filename}" ] && usage
+
+lineno="$2"
+
+[ -z "${lineno}" ] && usage
+
+line=$(git blame -L "${lineno}","${lineno}" "${filename}")
+sha=$(echo $line | awk '{print $1}')
+
+if [[ "${sha}" == "00000000" ]]; then
+  echo "${line}"
+else
+  git show "${sha}"
+fi
diff --git a/bin/git-blame-stats b/bin/git-blame-stats
new file mode 100755
index 0000000..4f83cba
--- /dev/null
+++ b/bin/git-blame-stats
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+use Getopt::Long;
+use POSIX qw(ceil);
+use strict;
+Getopt::Long::Configure(qw(bundling));
+my %authors;
+my $total;
+my $files;
+my $rev = shift(@ARGV) || "HEAD";
+
+foreach my $file (`git ls-tree --name-only -r $rev`) {
+  chomp($file);
+  print STDERR "Processing $file\n";
+  foreach my $line (`git blame -M -w $rev -- "$file"`) {
+    chomp($line);
+    if (substr($line, 0, 1) eq "^") {
+      ++$authors{"*initial checkin"};
+    } else {
+      $line =~ s[^.*?\((.*?)\s*\d{4}-\d{2}-\d{2}.*][$1];
+      ++$authors{$line};
+    }
+    ++$total;
+  }
+}
+
+print "Total lines: $total\n";
+my $i = 0;
+my $author_ind = ceil(log(scalar(keys %authors)) / log(10));
+my $lines_ind  = ceil(log($total) / log(10));
+foreach my $author (sort { $authors{$b} <=> $authors{$a} } keys %authors) {
+  printf "%${author_ind}s  %${lines_ind}u  %5.2f%%  %s\n",
+  sprintf("#%u", ++$i),
+  $authors{$author},
+  $authors{$author} * 100 / $total,
+  $author;
+}
diff --git a/bin/show-colors b/bin/show-colors
new file mode 100755
index 0000000..c2b8fe7
--- /dev/null
+++ b/bin/show-colors
@@ -0,0 +1,63 @@
+#!/usr/bin/env perl
+# Author: Todd Larason <jtl@molehill.org>
+# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
+
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+# colors 16-231 are a 6x6x6 color cube
+for ($red = 0; $red < 6; $red++) {
+    for ($green = 0; $green < 6; $green++) {
+	for ($blue = 0; $blue < 6; $blue++) {
+	    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
+		   16 + ($red * 36) + ($green * 6) + $blue,
+		   ($red ? ($red * 40 + 55) : 0),
+		   ($green ? ($green * 40 + 55) : 0),
+		   ($blue ? ($blue * 40 + 55) : 0));
+	}
+    }
+}
+
+# colors 232-255 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 24; $gray++) {
+    $level = ($gray * 10) + 8;
+    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
+	   232 + $gray, $level, $level, $level);
+}
+
+
+# display the colors
+
+# first the system ones:
+print "System colors:\n";
+for ($color = 0; $color < 8; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
+for ($color = 8; $color < 16; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n\n";
+
+# now the color cube
+print "Color cube, 6x6x6:\n";
+for ($green = 0; $green < 6; $green++) {
+    for ($red = 0; $red < 6; $red++) {
+	for ($blue = 0; $blue < 6; $blue++) {
+	    $color = 16 + ($red * 36) + ($green * 6) + $blue;
+	    print "\x1b[48;5;${color}m  ";
+	}
+	print "\x1b[0m ";
+    }
+    print "\n";
+}
+
+
+# now the grayscale ramp
+print "Grayscale ramp:\n";
+for ($color = 232; $color < 256; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
diff --git a/bin/sync-shell-files b/bin/sync-shell-files
new file mode 100755
index 0000000..dca1262
--- /dev/null
+++ b/bin/sync-shell-files
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+to_host="$1"
+
+if [[ -z "${to_host}" ]]; then
+  echo "usage: $0 <host>"
+  exit 1
+fi
+
+files="inputrc gitconfig"
+for file in $files; do
+  rsync -avz --delete "${HOME}/src/dotfiles/${file}" "${to_host}:.${file}"
+done
+
+[ -f "${HOME}/.gitconfig.private" ] && rsync -avz --delete "${HOME}/.gitconfig.private" "${to_host}:"
diff --git a/bin/tgz b/bin/tgz
new file mode 100755
index 0000000..7b8d05e
--- /dev/null
+++ b/bin/tgz
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+name=$1
+
+shift
+
+if [[ -z "${name}" ]]; then
+  echo "usage: $0 [name] [files]"
+  exit 1
+fi
+
+tar czfv "${name}.tgz" "$@"
diff --git a/gitconfig b/gitconfig
new file mode 100644
index 0000000..50d6bfd
--- /dev/null
+++ b/gitconfig
@@ -0,0 +1,33 @@
+[color]
+        status = auto
+        branch = auto
+        diff = auto
+
+[i18n]
+        commitencoding = utf-8
+
+[alias]
+        amend = commit --amend
+        br = branch
+        ci = commit
+        co = checkout
+        fixup = rebase -i HEAD~5
+        g = "grep --heading --break"
+        lt = log --oneline --graph --all
+        pending = !GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD) && git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline
+        pr = pull --rebase
+        st = status  -s
+        stat = show HEAD --stat
+[core]
+        whitespace = trailing-space,space-before-tab
+        excludesfile = ~/.gitignore
+        pager = less -+$LESS -R
+
+[branch]
+        autosetuprebase = remote
+
+[include]
+        path = ~/.gitconfig.private
+
+[http]
+        postBuffer = 524288000
diff --git a/gitignore b/gitignore
new file mode 100644
index 0000000..0e13c9b
--- /dev/null
+++ b/gitignore
@@ -0,0 +1,10 @@
+.DS_Store
+.idea
+*.iml
+/env/*
+# python stuff
+.flake8rc
+*pyc
+# ctags stuff
+TAGS
+tags
diff --git a/tmux.conf b/tmux.conf
new file mode 100644
index 0000000..0194bde
--- /dev/null
+++ b/tmux.conf
@@ -0,0 +1,29 @@
+set -g prefix ^z
+unbind C-b
+set -g default-terminal "screen-256color"
+set -g mouse-select-pane on
+set -g history-limit 4096
+set -g status on
+set -g set-titles on
+set -g renumber-windows on
+setw -g utf8 on
+setw -g aggressive-resize on
+
+set -g escape-time 50
+
+bind f send-prefix
+bind ^F choose-window
+bind ^N new-window
+bind ^D detach-client
+bind ^[ copy-mode
+bind | split-window -h
+bind - split-window -v
+
+new-session -s work
+new-session -s main
+new-session -s misc
+
+set -g status-right '#h'
+
+set -g status-bg white
+set -g status-fg black
diff --git a/vimrc b/vimrc
new file mode 100644
index 0000000..8627b27
--- /dev/null
+++ b/vimrc
@@ -0,0 +1,55 @@
+syn off
+set nocompatible
+let mapleader=","
+filetype indent plugin on
+set autoread
+set nojoinspaces
+set list lcs=trail:·,tab:»·
+set hlsearch
+set incsearch
+set ignorecase
+set showmatch
+set matchtime=1
+set encoding=utf-8
+set winminheight=0
+set hidden " allows files to be open in invisible buffers
+set wildmenu
+set wildmode=full
+set smartcase
+
+" seriously, no backup
+set nobackup
+set nowritebackup
+set noswapfile
+
+set expandtab
+set tabstop=2
+set shiftwidth=2
+set softtabstop=2
+set textwidth=80
+set smarttab
+set autoindent
+set nocindent
+
+highlight ExtraWhitespace ctermbg=red guibg=red
+match ExtraWhitespace /\s\+$/
+
+autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
+autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
+autocmd InsertLeave * match ExtraWhitespace /\s\+$/
+autocmd BufWinLeave * call clearmatches()
+
+au BufRead,BufNewFile *.json   setlocal filetype=javascript
+au BufRead,BufNewFile *.md     setlocal filetype=markdown
+au BufRead,BufNewFile *.mesos  setlocal filetype=python
+au BufRead,BufNewFile *.aurora setlocal filetype=python
+au BufRead,BufNewFile BUILD    setlocal filetype=python
+au BufRead,BufNewFile *.pp     setlocal filetype=ruby
+au BufRead,BufNewFile *.alert  setlocal filetype=yaml
+au BufRead,BufNewFile *.go     setlocal filetype=go
+
+au FileType python   setlocal keywordprg=pydoc shiftwidth=2 softtabstop=2 tabstop=2 tw=100
+au FileType make     setlocal shiftwidth=8 tabstop=8 noexpandtab
+au FileType markdown setlocal tw=100
+au FileType sh       setlocal shiftwidth=2 softtabstop=2 tabstop=2 tw=80
+au FileType go       setlocal tw=101 noexpandtab tabstop=4 shiftwidth=4 nolist