Compare commits
	
		
			47 Commits
		
	
	
		
			v0.0.1
			...
			a6973ace15
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a6973ace15 | |||
| 
						 | 
					2755650734 | ||
| 
						 | 
					4b36c35285 | ||
| 
						 | 
					12ba7965a4 | ||
| 
						 | 
					a67b2ace9e | ||
| 2559f7b69e | |||
| 1ef3690fbc | |||
| 
						 | 
					2cdb12a071 | ||
| 
						 | 
					116fcc44c4 | ||
| 
						 | 
					ebddd9bb7f | ||
| 
						 | 
					38a0a2fa3d | ||
| b21c4e4d12 | |||
| 3cbff4da78 | |||
| 
						 | 
					1415dec58b | ||
| 
						 | 
					9a9d1beb88 | ||
| 
						 | 
					b3e4231ae0 | ||
| 
						 | 
					79074be926 | ||
| 
						 | 
					ba33a48144 | ||
| 
						 | 
					882d2087cc | ||
| 
						 | 
					5c5efbe77d | ||
| 
						 | 
					9eaea22b9f | ||
| 
						 | 
					f3c4c0275a | ||
| 
						 | 
					bb4576886d | ||
| 
						 | 
					0e4fd52450 | ||
| eb61134f29 | |||
| e194d43baa | |||
| 1aa504dda8 | |||
| 43585e1519 | |||
| 5da5ecef49 | |||
| 2c4229696e | |||
| bdc6a5856b | |||
| 56a65c36c5 | |||
| 5e9e061e4f | |||
| 8e3b0a28e9 | |||
| fd237f2e62 | |||
| fb10240506 | |||
| 646138bb6b | |||
| 
						 | 
					f91e0e90ab | ||
| 
						 | 
					e534a8de0e | ||
| 
						 | 
					b36abc6f30 | ||
| 
						 | 
					8358cb6759 | ||
| 
						 | 
					bfa37857c6 | ||
| 
						 | 
					3d9e4513a3 | ||
| 
						 | 
					7d4c9b54e7 | ||
| 
						 | 
					cfd3316811 | ||
| 
						 | 
					604b094cea | ||
| ae3b45b0ab | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
*.cache
 | 
			
		||||
sublime/User/Package Control.last-run
 | 
			
		||||
sublime/User/Package Control.system-ca-bundle
 | 
			
		||||
bash_completion.d
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								bash_completion.d/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								bash_completion.d/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										5
									
								
								bash_completion.d/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								bash_completion.d/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# Adding new completions
 | 
			
		||||
 | 
			
		||||
Add a file ending with the `.sh` extension, which contains the completion
 | 
			
		||||
configuration. This will then automatically be picked up.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										126
									
								
								bin/battery
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										126
									
								
								bin/battery
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,126 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
HEART_FULL=♥
 | 
			
		||||
HEART_EMPTY=♡
 | 
			
		||||
[ -z "$NUM_HEARTS" ] &&
 | 
			
		||||
    NUM_HEARTS=5
 | 
			
		||||
 | 
			
		||||
cutinate()
 | 
			
		||||
{
 | 
			
		||||
    perc=$1
 | 
			
		||||
    inc=$(( 100 / $NUM_HEARTS))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    for i in `seq $NUM_HEARTS`; do
 | 
			
		||||
        if [ $perc -lt 100 ]; then
 | 
			
		||||
            echo $HEART_EMPTY
 | 
			
		||||
        else
 | 
			
		||||
            echo $HEART_FULL
 | 
			
		||||
        fi
 | 
			
		||||
        perc=$(( $perc + $inc ))
 | 
			
		||||
    done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
linux_get_bat ()
 | 
			
		||||
{
 | 
			
		||||
    bf=$(cat $BAT_FULL)
 | 
			
		||||
    bn=$(cat $BAT_NOW)
 | 
			
		||||
    echo $(( 100 * $bn / $bf ))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
freebsd_get_bat ()
 | 
			
		||||
{
 | 
			
		||||
    sysctl -n hw.acpi.battery.life
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Do with grep and awk unless too hard
 | 
			
		||||
 | 
			
		||||
# TODO Identify which machine we're on from teh script.
 | 
			
		||||
 | 
			
		||||
battery_status()
 | 
			
		||||
{
 | 
			
		||||
case $(uname -s) in
 | 
			
		||||
    "Linux")
 | 
			
		||||
        BATPATH=${BATPATH:-/sys/class/power_supply/BAT0}
 | 
			
		||||
        if [ ! -d $BATPATH ]; then
 | 
			
		||||
            exit 0
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        STATUS=$BATPATH/status
 | 
			
		||||
        [ "$1" = `cat $STATUS` ] || [ "$1" = "" ] || return 0
 | 
			
		||||
        if [ -f "$BATPATH/energy_full" ]; then
 | 
			
		||||
            naming="energy"
 | 
			
		||||
        elif [ -f "$BATPATH/charge_full" ]; then
 | 
			
		||||
            naming="charge"
 | 
			
		||||
        elif [ -f "$BATPATH/capacity" ]; then
 | 
			
		||||
            cat "$BATPATH/capacity"
 | 
			
		||||
            return 0
 | 
			
		||||
        fi
 | 
			
		||||
        BAT_FULL=$BATPATH/${naming}_full
 | 
			
		||||
        BAT_NOW=$BATPATH/${naming}_now
 | 
			
		||||
        linux_get_bat
 | 
			
		||||
        ;;
 | 
			
		||||
    "FreeBSD")
 | 
			
		||||
        STATUS=`sysctl -n hw.acpi.battery.state`
 | 
			
		||||
        case $1 in
 | 
			
		||||
            "Discharging")
 | 
			
		||||
                if [ $STATUS -eq 1 ]; then
 | 
			
		||||
                    freebsd_get_bat
 | 
			
		||||
                fi
 | 
			
		||||
                ;;
 | 
			
		||||
            "Charging")
 | 
			
		||||
                if [ $STATUS -eq 2 ]; then
 | 
			
		||||
                    freebsd_get_bat
 | 
			
		||||
                fi
 | 
			
		||||
                ;;
 | 
			
		||||
            "")
 | 
			
		||||
                freebsd_get_bat
 | 
			
		||||
                ;;
 | 
			
		||||
        esac
 | 
			
		||||
        ;;
 | 
			
		||||
    "Darwin")
 | 
			
		||||
        case $1 in
 | 
			
		||||
            "Discharging")
 | 
			
		||||
                ext="No";;
 | 
			
		||||
            "Charging")
 | 
			
		||||
                ext="Yes";;
 | 
			
		||||
        esac
 | 
			
		||||
 | 
			
		||||
        ioreg -c AppleSmartBattery -w0 | \
 | 
			
		||||
        grep -o '"[^"]*" = [^ ]*' | \
 | 
			
		||||
        sed -e 's/= //g' -e 's/"//g' | \
 | 
			
		||||
        sort | \
 | 
			
		||||
        while read key value; do
 | 
			
		||||
            case $key in
 | 
			
		||||
                "MaxCapacity")
 | 
			
		||||
                    export maxcap=$value;;
 | 
			
		||||
                "CurrentCapacity")
 | 
			
		||||
                    export curcap=$value;;
 | 
			
		||||
                "ExternalConnected")
 | 
			
		||||
                    if [ -n "$ext" ] && [ "$ext" != "$value" ]; then
 | 
			
		||||
                        exit
 | 
			
		||||
                    fi
 | 
			
		||||
                ;;
 | 
			
		||||
                "FullyCharged")
 | 
			
		||||
                    if [ "$value" = "Yes" ]; then
 | 
			
		||||
                        exit
 | 
			
		||||
                    fi
 | 
			
		||||
                ;;
 | 
			
		||||
            esac
 | 
			
		||||
            if [[ -n "$maxcap" && -n $curcap ]]; then
 | 
			
		||||
                echo $(( 100 * $curcap / $maxcap ))
 | 
			
		||||
                break
 | 
			
		||||
            fi
 | 
			
		||||
        done
 | 
			
		||||
esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
BATTERY_STATUS=`battery_status $1`
 | 
			
		||||
[ -z "$BATTERY_STATUS" ] && exit
 | 
			
		||||
 | 
			
		||||
if [ -n "$CUTE_BATTERY_INDICATOR" ]; then
 | 
			
		||||
    cutinate $BATTERY_STATUS
 | 
			
		||||
else
 | 
			
		||||
    echo ${BATTERY_STATUS}%
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								bin/composer
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/composer
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										15
									
								
								bin/dcdebug
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								bin/dcdebug
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
COMMAND=$1;
 | 
			
		||||
shift 1
 | 
			
		||||
 | 
			
		||||
if [ ! -f $COMMAND ]; then
 | 
			
		||||
    COMMAND=`which ${COMMAND}`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ ! -f "${COMMAND}" ]; then
 | 
			
		||||
    echo "Usage: ${0} <command>"
 | 
			
		||||
    exit 1;
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
PHP_IDE_CONFIG="serverName=local" XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0" php -d zend_extension=xdebug.so $COMMAND "$@"
 | 
			
		||||
							
								
								
									
										2
									
								
								bin/docker-php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2
									
								
								bin/docker-php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
docker run --rm -it --entrypoint /usr/bin/php --user $(id -u):$(id -g) -e HOME="${HOME}" -v ${HOME}:${HOME} --workdir $(pwd) php:70 $@
 | 
			
		||||
							
								
								
									
										5
									
								
								bin/git-fixup
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										5
									
								
								bin/git-fixup
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
set -e
 | 
			
		||||
TARGET=$(git rev-parse ${1})
 | 
			
		||||
git commit --fixup=${TARGET} ${@:2}
 | 
			
		||||
EDITOR=true git rebase -i --autostash --autosquash ${TARGET}^;
 | 
			
		||||
							
								
								
									
										99
									
								
								bin/git-test-sequence
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										99
									
								
								bin/git-test-sequence
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,99 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
# Run a command over a sequence of commits.
 | 
			
		||||
# Example:
 | 
			
		||||
#  git test-sequence origin/master.. 'make clean && make test'
 | 
			
		||||
 | 
			
		||||
. "$(git --exec-path)/git-sh-setup"
 | 
			
		||||
require_work_tree
 | 
			
		||||
 | 
			
		||||
t=
 | 
			
		||||
force=
 | 
			
		||||
run_once=
 | 
			
		||||
ref_name=pass
 | 
			
		||||
 | 
			
		||||
# The tree must be really really clean.
 | 
			
		||||
if ! git update-index --ignore-submodules --refresh > /dev/null; then
 | 
			
		||||
    echo >&2 "cannot rebase: you have unstaged changes"
 | 
			
		||||
    git diff-files --name-status -r --ignore-submodules -- >&2
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
 | 
			
		||||
case "$diff" in
 | 
			
		||||
    ?*) echo >&2 "cannot rebase: your index contains uncommitted changes"
 | 
			
		||||
        echo >&2 "$diff"
 | 
			
		||||
        exit 1
 | 
			
		||||
        ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
start_branch=`git rev-parse --symbolic-full-name HEAD | sed s,refs/heads/,,`
 | 
			
		||||
git checkout `git rev-parse HEAD` > /dev/null 2>/dev/null
 | 
			
		||||
 | 
			
		||||
cleanup() {
 | 
			
		||||
    git checkout $start_branch > /dev/null 2>/dev/null
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
already_passed() {
 | 
			
		||||
    obdata=${ref_name}-$t-$1
 | 
			
		||||
    obhash=`echo $obdata | git hash-object --stdin`
 | 
			
		||||
    git cat-file blob $obhash > /dev/null 2>/dev/null \
 | 
			
		||||
        && echo "Already ${ref_name} $1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
passed_on() {
 | 
			
		||||
    obdata=${ref_name}-$t-$1
 | 
			
		||||
    echo $obdata | git hash-object -w --stdin > /dev/null
 | 
			
		||||
    echo "Passed: $1."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
broke_on() {
 | 
			
		||||
    git log --pretty="format:Broke on %H (%s)%n" -n 1 $1
 | 
			
		||||
    cleanup
 | 
			
		||||
    exit 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
new_test() {
 | 
			
		||||
    echo "Testing $2"
 | 
			
		||||
    git reset --hard $v && eval "$2" && passed_on $1 || broke_on $v
 | 
			
		||||
    status=$?
 | 
			
		||||
    if test -n "$run_once"; then
 | 
			
		||||
        cleanup
 | 
			
		||||
        exit $status
 | 
			
		||||
    fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
while test $# != 0
 | 
			
		||||
do
 | 
			
		||||
    case "$1" in
 | 
			
		||||
        --force)
 | 
			
		||||
            force=yes
 | 
			
		||||
            ;;
 | 
			
		||||
        --once)
 | 
			
		||||
            run_once=yes
 | 
			
		||||
            ;;
 | 
			
		||||
        --ref-name)
 | 
			
		||||
            ref_name=$2
 | 
			
		||||
            shift
 | 
			
		||||
            ;;
 | 
			
		||||
        *)
 | 
			
		||||
            break;
 | 
			
		||||
            ;;
 | 
			
		||||
    esac
 | 
			
		||||
    shift
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
t=`echo "$2" | git hash-object --stdin`
 | 
			
		||||
 | 
			
		||||
for v in `git rev-list --reverse $1`
 | 
			
		||||
do
 | 
			
		||||
    tree_ver=`git rev-parse "$v^{tree}"`
 | 
			
		||||
    test -z "$force" && already_passed $tree_ver || new_test $tree_ver "$2"
 | 
			
		||||
done
 | 
			
		||||
cleanup
 | 
			
		||||
 | 
			
		||||
if test -n "$run_once"; then
 | 
			
		||||
    echo "All commits already passed for --once argument. Quiting."
 | 
			
		||||
    exit 127
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "All's well."
 | 
			
		||||
							
								
								
									
										17
									
								
								bin/release
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								bin/release
									
									
									
									
									
								
							@@ -32,6 +32,17 @@ if [ "$1" == "" ]; then
 | 
			
		||||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
git pull
 | 
			
		||||
 | 
			
		||||
# Make sure all changes are merged.
 | 
			
		||||
if [ $? -ne 0 ]; then
 | 
			
		||||
    error "Branch did not contain the latest changes and could not be merged automatically."
 | 
			
		||||
    echo "Please merge by hand before continue."
 | 
			
		||||
    echo
 | 
			
		||||
    git status
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Dirty repo?
 | 
			
		||||
if [ "$(git status --porcelain 2>/dev/null)" ]; then
 | 
			
		||||
	error "Repo is dirty."
 | 
			
		||||
@@ -45,6 +56,7 @@ fi
 | 
			
		||||
jq_ver=$(find . -maxdepth 1 -name "*.jquery.json" | xargs cat | jq -r ".version")
 | 
			
		||||
cmpnt_ver=$(find . -maxdepth 1 -name "bower.json" | xargs cat | jq -r ".version")
 | 
			
		||||
pkg_ver=$(find . -maxdepth 1 -name "package.json" | xargs cat | jq -r ".version")
 | 
			
		||||
git_ver=$(git tag | sort -rV | head -n1)
 | 
			
		||||
 | 
			
		||||
# Non npm package 
 | 
			
		||||
[ "$pkg_ver" == "0.0.0" ] && pkg_ver=
 | 
			
		||||
@@ -54,6 +66,7 @@ current_ver=
 | 
			
		||||
[ -n "$jq_ver" ] && current_ver="$jq_ver"
 | 
			
		||||
[ -n "$cmpnt_ver" ] && current_ver="$cmpnt_ver"
 | 
			
		||||
[ -n "$pkg_ver" ] && current_ver="$pkg_ver"
 | 
			
		||||
[ -n "$git_ver" ] && current_ver="$git_ver"
 | 
			
		||||
[ -z "$current_ver" ] && current_ver="0.0.0"
 | 
			
		||||
 | 
			
		||||
# Validate current versions and determine new version
 | 
			
		||||
@@ -103,11 +116,11 @@ if [ -f src/Gruntfile.js ]; then
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Commit changed files
 | 
			
		||||
git commit -am "v$new_ver"
 | 
			
		||||
git commit -am "$new_ver"
 | 
			
		||||
git push origin
 | 
			
		||||
 | 
			
		||||
# Create tag
 | 
			
		||||
git tag "v$new_ver"
 | 
			
		||||
git tag "$new_ver"
 | 
			
		||||
git push origin --tags
 | 
			
		||||
 | 
			
		||||
# Publish npm package
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										66
									
								
								bin/setup-server
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										66
									
								
								bin/setup-server
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
NORMAL=$(tput sgr0)
 | 
			
		||||
GREEN=$(tput setaf 2; tput bold)
 | 
			
		||||
YELLOW=$(tput setaf 3)
 | 
			
		||||
RED=$(tput setaf 1)
 | 
			
		||||
 | 
			
		||||
function red() { echo -e "$RED$*$NORMAL"; }
 | 
			
		||||
function green() { echo -e "$GREEN$*$NORMAL"; }
 | 
			
		||||
function yellow() { echo -e "$YELLOW$*$NORMAL"; }
 | 
			
		||||
 | 
			
		||||
if [ $# -lt 1 ]; then
 | 
			
		||||
    echo "Usage: $0 <host|IP> [friendly-name] [user]"
 | 
			
		||||
    echo "Example: $0 127.0.0.1 server-name $USER"
 | 
			
		||||
    echo
 | 
			
		||||
    echo "Afterwards you can login with: ssh server-name"
 | 
			
		||||
    exit 1;
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
HOST=$1
 | 
			
		||||
NAME=$2
 | 
			
		||||
USERNAME=$3
 | 
			
		||||
 | 
			
		||||
IP=`dig +short $HOST`
 | 
			
		||||
 | 
			
		||||
if [ -z "$USERNAME" ]; then
 | 
			
		||||
    USERNAME=$USER
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "$IP" ]; then
 | 
			
		||||
    IP=$HOST
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -z "$NAME" ]; then
 | 
			
		||||
    NAME=$HOST
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
yellow "Setting up server $USERNAME@$HOST with name '$NAME'"
 | 
			
		||||
 | 
			
		||||
grep "Host $NAME" ~/.ssh/config 2>&1 > /dev/null
 | 
			
		||||
 | 
			
		||||
if [ 0 -eq $? ]; then
 | 
			
		||||
    echo $NAME is already in .ssh/config
 | 
			
		||||
else
 | 
			
		||||
    echo Adding server to .ssh/config...
 | 
			
		||||
    cat >> ~/.ssh/config <<END_OF_HOST
 | 
			
		||||
Host $NAME
 | 
			
		||||
    HostName $IP
 | 
			
		||||
    User     $USERNAME
 | 
			
		||||
 | 
			
		||||
END_OF_HOST
 | 
			
		||||
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo Copying .ssh directory...
 | 
			
		||||
scp -qr $HOME/.ssh/ $NAME:
 | 
			
		||||
 | 
			
		||||
echo Installing dotfiles...
 | 
			
		||||
ssh $NAME 'find . -maxdepth 1 -type l -exec unlink {} \;; rm $HOME/.bash*; curl -s https://dot.jacobkiers.net | bash'
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
green "Done installing server. You can now log in with: ssh $NAME"
 | 
			
		||||
 | 
			
		||||
green "As a convenience, you will be logged in immediately."
 | 
			
		||||
 | 
			
		||||
ssh $NAME
 | 
			
		||||
							
								
								
									
										26
									
								
								bin/wav2alaw
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								bin/wav2alaw
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Converts all wav-files in a directory to alaw.
 | 
			
		||||
 | 
			
		||||
if [[  -z "$1" ]]; then
 | 
			
		||||
    DIR='.'
 | 
			
		||||
else
 | 
			
		||||
    if [ ! -d "$1" ]; then
 | 
			
		||||
        echo "Directory does not exist!"
 | 
			
		||||
        exit
 | 
			
		||||
    else
 | 
			
		||||
        DIR=$1
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
cd $DIR
 | 
			
		||||
for f in `ls -1 *.wav | sed 's/\.[^.]*$//' | sort -n`; do
 | 
			
		||||
    echo "Converting $f.wav to $f.alaw..."
 | 
			
		||||
    `sox $f.wav --channels 1 --encoding a-law --rate 8000 --type raw $f.alaw.wav`
 | 
			
		||||
    if [ $? -eq 0 ]; then
 | 
			
		||||
        `mv $f.alaw.wav $f.alaw`
 | 
			
		||||
        `rm $f.wav`
 | 
			
		||||
    fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
echo "Done."
 | 
			
		||||
							
								
								
									
										15
									
								
								bin/xdebug
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										15
									
								
								bin/xdebug
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
COMMAND=$1;
 | 
			
		||||
shift 1
 | 
			
		||||
 | 
			
		||||
if [ ! -f $COMMAND ]; then
 | 
			
		||||
    COMMAND=`which ${COMMAND}`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ ! -f "${COMMAND}" ]; then
 | 
			
		||||
    echo "Usage: ${0} <command>"
 | 
			
		||||
    exit 1;
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
PHP_IDE_CONFIG="serverName=local" XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0" php -d zend_extension=xdebug.so $COMMAND "$@"
 | 
			
		||||
@@ -7,21 +7,25 @@ alias ~="cd ~"
 | 
			
		||||
alias -- -="cd -"  # The alias is `-`, not `--`
 | 
			
		||||
 | 
			
		||||
# Shortcuts
 | 
			
		||||
alias c="composer"
 | 
			
		||||
alias c="php -dmemory_limit=2G $HOME/dotfiles/bin/composer"
 | 
			
		||||
alias e=$EDITOR
 | 
			
		||||
alias o="open"
 | 
			
		||||
alias oo="open ."
 | 
			
		||||
alias e=$EDITOR
 | 
			
		||||
alias gh="github"
 | 
			
		||||
alias +x="chmod +x"
 | 
			
		||||
alias t="tmux"
 | 
			
		||||
alias x+="chmod +x"
 | 
			
		||||
alias +x="chmod +x"
 | 
			
		||||
 | 
			
		||||
# Git
 | 
			
		||||
alias gs="git status"
 | 
			
		||||
alias gd="git diff"
 | 
			
		||||
alias gds="git diff --staged"
 | 
			
		||||
alias gc="git commit -sv"
 | 
			
		||||
alias rb="git rebase"
 | 
			
		||||
alias rbi="git rebase -i"
 | 
			
		||||
# Devstack
 | 
			
		||||
alias comup='pushd ~/src/comandi/dashboard; vagrant up; popd'
 | 
			
		||||
alias comdown='pushd ~/src/comandi/dashboard; vagrant halt; popd'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if [ `uname` == 'Linux' ]; then
 | 
			
		||||
    alias open='xdg-open'
 | 
			
		||||
fi
 | 
			
		||||
# Remove all local branches already merged in master.
 | 
			
		||||
alias gitclean='git branch --merged master | grep -v "\smaster$" | grep -v "*" | xargs --no-run-if-empty git branch -d'
 | 
			
		||||
alias gist='gist -c'
 | 
			
		||||
 | 
			
		||||
# Detect which `ls` flavor is in use
 | 
			
		||||
if ls --color > /dev/null 2>&1; then  # GNU `ls`
 | 
			
		||||
@@ -46,7 +50,7 @@ alias myip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print \$2}'"
 | 
			
		||||
alias update="source "$HOME/dotfiles/setup/update.sh""
 | 
			
		||||
 | 
			
		||||
# Update dotfiles
 | 
			
		||||
alias dotfiles="pushd "$HOME/dotfiles" > /dev/null 2>&1; git pull && ./sync.py && . "$HOME/.bashrc"; popd > /dev/null 2>&1; nyan"
 | 
			
		||||
alias dotfiles="$HOME/dotfiles/update.sh"
 | 
			
		||||
 | 
			
		||||
# Clean up LaunchServices to remove duplicates in the “Open With” menu
 | 
			
		||||
#alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
 | 
			
		||||
@@ -81,7 +85,7 @@ alias get="curl -O"
 | 
			
		||||
alias dos2unix="perl -pi -e 's/\r\n?/\n/g'"
 | 
			
		||||
 | 
			
		||||
# Password generator
 | 
			
		||||
password() { cat /dev/urandom | tr -dc A-Za-z0-9_ | head -c ${1:-10}; }
 | 
			
		||||
password() { cat /dev/urandom 2>/dev/null | tr -dc A-Za-z0-9_ 2>/dev/null | head --bytes=${1:-10}; }
 | 
			
		||||
 | 
			
		||||
# Show $PATH in a readable way
 | 
			
		||||
alias path='echo -e ${PATH//:/\\n}'
 | 
			
		||||
@@ -103,3 +107,4 @@ alias dot-git="killall Marked; open -a marked --args $HOME/dotfiles/docs/Git.md"
 | 
			
		||||
alias dot-hub="killall Marked; find /usr/local/Cellar/hub/ -name README.md -exec open -a marked --args {} \;"
 | 
			
		||||
#alias dot-extras="killall Marked; find /usr/local/Cellar/git-extras/ -name README.md -exec open -a marked --args {} \;"
 | 
			
		||||
alias dot-extras="open https://github.com/visionmedia/git-extras/blob/master/Readme.md#readme"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								includes/bash_completion.bash
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								includes/bash_completion.bash
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
# If possible, add tab completion for many commands
 | 
			
		||||
[ -f /etc/bash_completion ] && source /etc/bash_completion
 | 
			
		||||
 | 
			
		||||
# Bash completion (installed via Homebrew; source after `brew` is added to PATH)
 | 
			
		||||
command -v brew >/dev/null 2>&1 && [ -r "$(brew --prefix)/etc/bash_completion" ] && source "$(brew --prefix)/etc/bash_completion"
 | 
			
		||||
 | 
			
		||||
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
 | 
			
		||||
function _ssh_reload_autocomplete() {
 | 
			
		||||
	[ -e "~/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
 | 
			
		||||
}
 | 
			
		||||
_ssh_reload_autocomplete
 | 
			
		||||
 | 
			
		||||
# Add AWS CLI Completion.
 | 
			
		||||
complete -C aws_completer aws
 | 
			
		||||
complete -F _tmux t
 | 
			
		||||
 | 
			
		||||
# Add Gush completion.
 | 
			
		||||
[ -f $HOME/.gush/.gush-autocomplete.bash ] && source $HOME/.gush/.gush-autocomplete.bash
 | 
			
		||||
 | 
			
		||||
if [ -d $HOME/dotfiles/bash_completion.d ];
 | 
			
		||||
then
 | 
			
		||||
    for file in `find $HOME/dotfiles/bash_completion.d/ -type f -name '*.sh'`
 | 
			
		||||
    do
 | 
			
		||||
        source $file
 | 
			
		||||
    done
 | 
			
		||||
fi
 | 
			
		||||
@@ -179,3 +179,8 @@ function git-private()
 | 
			
		||||
for cmd in password hex2hsl hex2rgb escape codepoint ssh-key myip; do
 | 
			
		||||
	eval "function $cmd+() { $cmd \$@ | c; }"
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
function jira()
 | 
			
		||||
{
 | 
			
		||||
    open "https://comandi.atlassian.net/browse/CMD-${1}"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@ function prompt_command() {
 | 
			
		||||
	PS2="\[$CYAN\]$prompt_symbol\[$NOCOLOR\] "
 | 
			
		||||
 | 
			
		||||
	# Terminal title
 | 
			
		||||
	local title="$(basename $PWD)"
 | 
			
		||||
	local title=`basename "$PWD"`
 | 
			
		||||
	[ -n "$remote" ] && title="$title \xE2\x80\x94 $HOSTNAME"
 | 
			
		||||
	echo -ne "\033]0;$title"; echo -ne "\007"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								includes/bash_ssh.bash
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								includes/bash_ssh.bash
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
if [ -z "$SSH_AUTH_SOCK" ] ; then
 | 
			
		||||
    eval `ssh-agent -s`
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
KEY="$HOME/.ssh/work"
 | 
			
		||||
 | 
			
		||||
[ -f $KEY ] || return;
 | 
			
		||||
 | 
			
		||||
ssh-add -l | grep $KEY > /dev/null || ssh-add $KEY
 | 
			
		||||
 | 
			
		||||
@@ -17,7 +17,7 @@ fi
 | 
			
		||||
 | 
			
		||||
# Clone dotfiles and make symlinks
 | 
			
		||||
echo "Installing dotfiles..."
 | 
			
		||||
cd ~ && git clone git@bitbucket.org:jacobkiers/dotfiles.git && cd dotfiles && ./sync.py
 | 
			
		||||
cd ~ && git clone https://bitbucket.org/jacobkiers/dotfiles.git && cd dotfiles && ./sync.py
 | 
			
		||||
source ~/.bashrc
 | 
			
		||||
echo "Dotfiles installed successfully."
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								resources/git-hooks/README.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								resources/git-hooks/README.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
You can add global git hooks in this directory.
 | 
			
		||||
							
								
								
									
										266
									
								
								resources/git-hooks/pre-commit
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										266
									
								
								resources/git-hooks/pre-commit
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,266 @@
 | 
			
		||||
#!/usr/bin/env php
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * .git/hooks/pre-commit
 | 
			
		||||
 *
 | 
			
		||||
 * This pre-commit hooks will check for PHP errors (lint), and make sure the
 | 
			
		||||
 * code is PSR-2 compliant.
 | 
			
		||||
 *
 | 
			
		||||
 * @author  Reen Lokum http://github.com/reenl
 | 
			
		||||
 *
 | 
			
		||||
 * The orignal version of this file can be found at:
 | 
			
		||||
 * https://github.com/zendframework/zf2/blob/master/README-GIT.md
 | 
			
		||||
 *
 | 
			
		||||
 * Extended with functionality found at:
 | 
			
		||||
 * http://kvz.io/blog/2013/12/29/one-git-commit-hook-to-rule-them-all/
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
$exit = 0;
 | 
			
		||||
 | 
			
		||||
// Initial commit
 | 
			
		||||
$against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
 | 
			
		||||
if (run('git rev-parse --verify HEAD > /dev/null')) {
 | 
			
		||||
    $against = 'HEAD';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Only run when we're on a branch (to avoid rebase hell)
 | 
			
		||||
// http://git-blame.blogspot.nl/2013/06/checking-current-branch-programatically.html
 | 
			
		||||
$branch = run('git symbolic-ref --short -q HEAD');
 | 
			
		||||
if (!$branch) {
 | 
			
		||||
    writeln('Not on any branch');
 | 
			
		||||
    exit(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * collect all files which have been added, copied or
 | 
			
		||||
 * modified and store them in an array called output
 | 
			
		||||
 */
 | 
			
		||||
$diffLines = array();
 | 
			
		||||
exec('git diff-index --cached --full-index --diff-filter=ACM '.$against, $diffLines);
 | 
			
		||||
 | 
			
		||||
writeln();
 | 
			
		||||
 | 
			
		||||
// Filter files that don't need a check.
 | 
			
		||||
foreach ($diffLines as $line) {
 | 
			
		||||
    $partList = preg_split('#\s+#', $line, 6);
 | 
			
		||||
    $hash = $partList[3];
 | 
			
		||||
    $status = $partList[4];
 | 
			
		||||
    $fileName = $partList[5];
 | 
			
		||||
    if ('D' === $status) {
 | 
			
		||||
        // deleted file; do nothing
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $type = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
 | 
			
		||||
    $validator = 'validator_'.$type;
 | 
			
		||||
    if (!$type || !function_exists($validator)) {
 | 
			
		||||
        $type = run("git cat-file -p ".$hash." | head -n1 | awk -F/ '/^#\!/ {print \$NF}' | sed 's/^env //g'");
 | 
			
		||||
        $validator = 'validator_'.$type;
 | 
			
		||||
        if (!function_exists($validator)) {
 | 
			
		||||
            // No validator
 | 
			
		||||
            writeln('  Skipping "'.format($fileName, 'green').'" no validator available.');
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    write('  Checking "'.format($fileName, 'green').'" with validator '.format($type, 'green').'.');
 | 
			
		||||
 | 
			
		||||
    $output = '';
 | 
			
		||||
    if (!$validator($hash, $fileName, $output)) {
 | 
			
		||||
        writeln(PHP_EOL.'X ERROR '.implode(PHP_EOL.'  ', explode(PHP_EOL, $output)).PHP_EOL, 'red');
 | 
			
		||||
        $exit = 1;
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
    writeln(' OK', 'green');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($exit > 0) {
 | 
			
		||||
    writeln(PHP_EOL."Please fix the above errors and run 'git add'.", 'gray');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exit($exit);
 | 
			
		||||
 | 
			
		||||
function validator_php($hash, $fileName, &$output)
 | 
			
		||||
{
 | 
			
		||||
    if (validator_php_syntax($hash, $fileName, $output)) {
 | 
			
		||||
        return validator_php_cs($hash, $fileName, $output);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function validator_php_syntax($hash, $fileName, &$output)
 | 
			
		||||
{
 | 
			
		||||
    $output = '';
 | 
			
		||||
    $exitCode = 0;
 | 
			
		||||
 | 
			
		||||
    $result = run('git cat-file -p '.escapeshellarg($hash).' | php -l', $output, $exitCode, "purge", "default");
 | 
			
		||||
    if ($result) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $output = 'Syntax Error'.PHP_EOL.$output;
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function validator_php_cs($hash, $fileName, &$output)
 | 
			
		||||
{
 | 
			
		||||
    // Use .php_cs config if project has one.
 | 
			
		||||
    $configFile = '';
 | 
			
		||||
    if (file_exists('.php_cs')) {
 | 
			
		||||
        $configFile = ' --config-file='.escapeshellarg(realpath('.php_cs'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $tmpDir = '/tmp/cs-check/'.$hash;
 | 
			
		||||
    $tmp =  $tmpDir.'/'.$fileName;
 | 
			
		||||
    run('mkdir -p '.dirname($tmp));
 | 
			
		||||
    run('git cat-file -p '.escapeshellarg($hash).' > '.$tmp);
 | 
			
		||||
 | 
			
		||||
    $return = null;
 | 
			
		||||
    run('php-cs-fixer fix --dry-run --verbose --level=symfony'.$configFile.' '.escapeshellarg($tmp), $currentOutput, $return, 'default', 'default');
 | 
			
		||||
 | 
			
		||||
    run('rm -rf '.escapeshellarg($tmpDir));
 | 
			
		||||
 | 
			
		||||
    // Check output
 | 
			
		||||
    if ($return !== 0) {
 | 
			
		||||
        $out = explode(PHP_EOL, $currentOutput);
 | 
			
		||||
 | 
			
		||||
        $rule = null;
 | 
			
		||||
        foreach ($out as $line) {
 | 
			
		||||
            if (preg_match('#\s+[0-9]+\)\s#', $line)) {
 | 
			
		||||
                $rule = $line;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($rule !== null && preg_match('#\((.*)\)#', $rule, $matches)) {
 | 
			
		||||
            $output = 'Code Style errors'.PHP_EOL.$matches[1];
 | 
			
		||||
        } else {
 | 
			
		||||
            $output = 'Code Style errors'.PHP_EOL.implode(PHP_EOL, $out).PHP_EOL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Runs like exec with a few changes:
 | 
			
		||||
 * - Output is returned as a string.
 | 
			
		||||
 * - Output is NOT appended.
 | 
			
		||||
 * - STDERR is also added to the output.
 | 
			
		||||
 * - STDERR and/or STDOUT can be disabled by passing purge.
 | 
			
		||||
 * - Returns the first output line if successful and false when failed.
 | 
			
		||||
 * - If no output is generated and the exit status equals 0 then true is returned.
 | 
			
		||||
 *
 | 
			
		||||
 * @param string $command
 | 
			
		||||
 * @param string &$output
 | 
			
		||||
 * @param int &$exitCode
 | 
			
		||||
 * @param string $stdout
 | 
			
		||||
 * @param string $stderr
 | 
			
		||||
 *
 | 
			
		||||
 * @return boolean
 | 
			
		||||
 */
 | 
			
		||||
function run($command, &$output = '', &$exitCode = 0, $stdout = 'default', $stderr = 'purge')
 | 
			
		||||
{
 | 
			
		||||
    $descriptors = array(
 | 
			
		||||
        0 => array("pipe", "r"),  // stdin
 | 
			
		||||
        1 => array("pipe", "w"),  // stdout
 | 
			
		||||
        2 => array("pipe", "w"),   // stderr
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    $pipes = array();
 | 
			
		||||
 | 
			
		||||
    $out = array();
 | 
			
		||||
    $process = proc_open($command, $descriptors, $pipes);
 | 
			
		||||
    fclose($pipes[0]);
 | 
			
		||||
    unset($pipes[0]);
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        $read = $pipes;
 | 
			
		||||
        $write  = $except = array();
 | 
			
		||||
        if (!stream_select($read, $write, $except, 5)) {
 | 
			
		||||
            writeln('Timeout on process: '.$command, 'red');
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($read as $pipe) {
 | 
			
		||||
            $pipeId = array_search($pipe, $pipes);
 | 
			
		||||
            if ($pipeId === false) {
 | 
			
		||||
                writeln('Unable to determine where the output came from.', 'red');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (feof($pipe)) {
 | 
			
		||||
                fclose($pipe);
 | 
			
		||||
                if ($pipeId !== false) {
 | 
			
		||||
                    unset($pipes[$pipeId]);
 | 
			
		||||
                }
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $line = fgets($pipe);
 | 
			
		||||
            if ($line === false) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $color = $stderr;
 | 
			
		||||
            if ($pipeId == 1) {
 | 
			
		||||
                $color = $stdout;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ($color != 'purge') {
 | 
			
		||||
                $out[] = format(rtrim($line), $color);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } while (count($pipes) > 0);
 | 
			
		||||
 | 
			
		||||
    $exitCode = proc_close($process);
 | 
			
		||||
    $output = implode(PHP_EOL, $out);
 | 
			
		||||
 | 
			
		||||
    if ($exitCode == 0) {
 | 
			
		||||
        if (!isset($out[0]) || $out[0] == '') {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $out[0];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function format($string, $color = 'default')
 | 
			
		||||
{
 | 
			
		||||
    if ($color == 'default') {
 | 
			
		||||
        return $string;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ($color == 'purge') {
 | 
			
		||||
        return '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $colors = array(
 | 
			
		||||
        'gray'  => 37,
 | 
			
		||||
        'green' => 32,
 | 
			
		||||
        'red'   => 31,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (!isset($colors[$color])) {
 | 
			
		||||
        writeln($color.' is not a valid color.');
 | 
			
		||||
        exit(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return chr(0x1B).'['.$colors[$color].'m'.$string.chr(0x1B).'[m';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function writeln($write = '', $color = 'default')
 | 
			
		||||
{
 | 
			
		||||
    write($write.PHP_EOL, $color);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function write($write = '', $color = 'default')
 | 
			
		||||
{
 | 
			
		||||
    echo format($write, $color);
 | 
			
		||||
    flush();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										0
									
								
								resources/git-template/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								resources/git-template/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								resources/git-template/hooks/README.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								resources/git-template/hooks/README.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
You can add global git hooks in this directory.
 | 
			
		||||
							
								
								
									
										266
									
								
								resources/git-template/hooks/pre-commit
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										266
									
								
								resources/git-template/hooks/pre-commit
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,266 @@
 | 
			
		||||
#!/usr/bin/env php
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * .git/hooks/pre-commit
 | 
			
		||||
 *
 | 
			
		||||
 * This pre-commit hooks will check for PHP errors (lint), and make sure the
 | 
			
		||||
 * code is PSR-2 compliant.
 | 
			
		||||
 *
 | 
			
		||||
 * @author  Reen Lokum http://github.com/reenl
 | 
			
		||||
 *
 | 
			
		||||
 * The orignal version of this file can be found at:
 | 
			
		||||
 * https://github.com/zendframework/zf2/blob/master/README-GIT.md
 | 
			
		||||
 *
 | 
			
		||||
 * Extended with functionality found at:
 | 
			
		||||
 * http://kvz.io/blog/2013/12/29/one-git-commit-hook-to-rule-them-all/
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
$exit = 0;
 | 
			
		||||
 | 
			
		||||
// Initial commit
 | 
			
		||||
$against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
 | 
			
		||||
if (run('git rev-parse --verify HEAD > /dev/null')) {
 | 
			
		||||
    $against = 'HEAD';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Only run when we're on a branch (to avoid rebase hell)
 | 
			
		||||
// http://git-blame.blogspot.nl/2013/06/checking-current-branch-programatically.html
 | 
			
		||||
$branch = run('git symbolic-ref --short -q HEAD');
 | 
			
		||||
if (!$branch) {
 | 
			
		||||
    writeln('Not on any branch');
 | 
			
		||||
    exit(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * collect all files which have been added, copied or
 | 
			
		||||
 * modified and store them in an array called output
 | 
			
		||||
 */
 | 
			
		||||
$diffLines = array();
 | 
			
		||||
exec('git diff-index --cached --full-index --diff-filter=ACM '.$against, $diffLines);
 | 
			
		||||
 | 
			
		||||
writeln();
 | 
			
		||||
 | 
			
		||||
// Filter files that don't need a check.
 | 
			
		||||
foreach ($diffLines as $line) {
 | 
			
		||||
    $partList = preg_split('#\s+#', $line, 6);
 | 
			
		||||
    $hash = $partList[3];
 | 
			
		||||
    $status = $partList[4];
 | 
			
		||||
    $fileName = $partList[5];
 | 
			
		||||
    if ('D' === $status) {
 | 
			
		||||
        // deleted file; do nothing
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $type = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
 | 
			
		||||
    $validator = 'validator_'.$type;
 | 
			
		||||
    if (!$type || !function_exists($validator)) {
 | 
			
		||||
        $type = run("git cat-file -p ".$hash." | head -n1 | awk -F/ '/^#\!/ {print \$NF}' | sed 's/^env //g'");
 | 
			
		||||
        $validator = 'validator_'.$type;
 | 
			
		||||
        if (!function_exists($validator)) {
 | 
			
		||||
            // No validator
 | 
			
		||||
            writeln('  Skipping "'.format($fileName, 'green').'" no validator available.');
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    write('  Checking "'.format($fileName, 'green').'" with validator '.format($type, 'green').'.');
 | 
			
		||||
 | 
			
		||||
    $output = '';
 | 
			
		||||
    if (!$validator($hash, $fileName, $output)) {
 | 
			
		||||
        writeln(PHP_EOL.'X ERROR '.implode(PHP_EOL.'  ', explode(PHP_EOL, $output)).PHP_EOL, 'red');
 | 
			
		||||
        $exit = 1;
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
    writeln(' OK', 'green');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($exit > 0) {
 | 
			
		||||
    writeln(PHP_EOL."Please fix the above errors and run 'git add'.", 'gray');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exit($exit);
 | 
			
		||||
 | 
			
		||||
function validator_php($hash, $fileName, &$output)
 | 
			
		||||
{
 | 
			
		||||
    if (validator_php_syntax($hash, $fileName, $output)) {
 | 
			
		||||
        return validator_php_cs($hash, $fileName, $output);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function validator_php_syntax($hash, $fileName, &$output)
 | 
			
		||||
{
 | 
			
		||||
    $output = '';
 | 
			
		||||
    $exitCode = 0;
 | 
			
		||||
 | 
			
		||||
    $result = run('git cat-file -p '.escapeshellarg($hash).' | php -l', $output, $exitCode, "purge", "default");
 | 
			
		||||
    if ($result) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $output = 'Syntax Error'.PHP_EOL.$output;
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function validator_php_cs($hash, $fileName, &$output)
 | 
			
		||||
{
 | 
			
		||||
    // Use .php_cs config if project has one.
 | 
			
		||||
    $configFile = '';
 | 
			
		||||
    if (file_exists('.php_cs')) {
 | 
			
		||||
        $configFile = ' --config-file='.escapeshellarg(realpath('.php_cs'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $tmpDir = '/tmp/cs-check/'.$hash;
 | 
			
		||||
    $tmp =  $tmpDir.'/'.$fileName;
 | 
			
		||||
    run('mkdir -p '.dirname($tmp));
 | 
			
		||||
    run('git cat-file -p '.escapeshellarg($hash).' > '.$tmp);
 | 
			
		||||
 | 
			
		||||
    $return = null;
 | 
			
		||||
    run('php-cs-fixer fix --dry-run --verbose --level=symfony'.$configFile.' '.escapeshellarg($tmp), $currentOutput, $return, 'default', 'default');
 | 
			
		||||
 | 
			
		||||
    run('rm -rf '.escapeshellarg($tmpDir));
 | 
			
		||||
 | 
			
		||||
    // Check output
 | 
			
		||||
    if ($return !== 0) {
 | 
			
		||||
        $out = explode(PHP_EOL, $currentOutput);
 | 
			
		||||
 | 
			
		||||
        $rule = null;
 | 
			
		||||
        foreach ($out as $line) {
 | 
			
		||||
            if (preg_match('#\s+[0-9]+\)\s#', $line)) {
 | 
			
		||||
                $rule = $line;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($rule !== null && preg_match('#\((.*)\)#', $rule, $matches)) {
 | 
			
		||||
            $output = 'Code Style errors'.PHP_EOL.$matches[1];
 | 
			
		||||
        } else {
 | 
			
		||||
            $output = 'Code Style errors'.PHP_EOL.implode(PHP_EOL, $out).PHP_EOL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Runs like exec with a few changes:
 | 
			
		||||
 * - Output is returned as a string.
 | 
			
		||||
 * - Output is NOT appended.
 | 
			
		||||
 * - STDERR is also added to the output.
 | 
			
		||||
 * - STDERR and/or STDOUT can be disabled by passing purge.
 | 
			
		||||
 * - Returns the first output line if successful and false when failed.
 | 
			
		||||
 * - If no output is generated and the exit status equals 0 then true is returned.
 | 
			
		||||
 *
 | 
			
		||||
 * @param string $command
 | 
			
		||||
 * @param string &$output
 | 
			
		||||
 * @param int &$exitCode
 | 
			
		||||
 * @param string $stdout
 | 
			
		||||
 * @param string $stderr
 | 
			
		||||
 *
 | 
			
		||||
 * @return boolean
 | 
			
		||||
 */
 | 
			
		||||
function run($command, &$output = '', &$exitCode = 0, $stdout = 'default', $stderr = 'purge')
 | 
			
		||||
{
 | 
			
		||||
    $descriptors = array(
 | 
			
		||||
        0 => array("pipe", "r"),  // stdin
 | 
			
		||||
        1 => array("pipe", "w"),  // stdout
 | 
			
		||||
        2 => array("pipe", "w"),   // stderr
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    $pipes = array();
 | 
			
		||||
 | 
			
		||||
    $out = array();
 | 
			
		||||
    $process = proc_open($command, $descriptors, $pipes);
 | 
			
		||||
    fclose($pipes[0]);
 | 
			
		||||
    unset($pipes[0]);
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        $read = $pipes;
 | 
			
		||||
        $write  = $except = array();
 | 
			
		||||
        if (!stream_select($read, $write, $except, 5)) {
 | 
			
		||||
            writeln('Timeout on process: '.$command, 'red');
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($read as $pipe) {
 | 
			
		||||
            $pipeId = array_search($pipe, $pipes);
 | 
			
		||||
            if ($pipeId === false) {
 | 
			
		||||
                writeln('Unable to determine where the output came from.', 'red');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (feof($pipe)) {
 | 
			
		||||
                fclose($pipe);
 | 
			
		||||
                if ($pipeId !== false) {
 | 
			
		||||
                    unset($pipes[$pipeId]);
 | 
			
		||||
                }
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $line = fgets($pipe);
 | 
			
		||||
            if ($line === false) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $color = $stderr;
 | 
			
		||||
            if ($pipeId == 1) {
 | 
			
		||||
                $color = $stdout;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ($color != 'purge') {
 | 
			
		||||
                $out[] = format(rtrim($line), $color);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } while (count($pipes) > 0);
 | 
			
		||||
 | 
			
		||||
    $exitCode = proc_close($process);
 | 
			
		||||
    $output = implode(PHP_EOL, $out);
 | 
			
		||||
 | 
			
		||||
    if ($exitCode == 0) {
 | 
			
		||||
        if (!isset($out[0]) || $out[0] == '') {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $out[0];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function format($string, $color = 'default')
 | 
			
		||||
{
 | 
			
		||||
    if ($color == 'default') {
 | 
			
		||||
        return $string;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ($color == 'purge') {
 | 
			
		||||
        return '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $colors = array(
 | 
			
		||||
        'gray'  => 37,
 | 
			
		||||
        'green' => 32,
 | 
			
		||||
        'red'   => 31,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (!isset($colors[$color])) {
 | 
			
		||||
        writeln($color.' is not a valid color.');
 | 
			
		||||
        exit(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return chr(0x1B).'['.$colors[$color].'m'.$string.chr(0x1B).'[m';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function writeln($write = '', $color = 'default')
 | 
			
		||||
{
 | 
			
		||||
    write($write.PHP_EOL, $color);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function write($write = '', $color = 'default')
 | 
			
		||||
{
 | 
			
		||||
    echo format($write, $color);
 | 
			
		||||
    flush();
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,73 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
source "$HOME/dotfiles/includes/installer.sh"
 | 
			
		||||
if command -v brew >/dev/null 2>&1; then
 | 
			
		||||
    brew install caskroom/cask/brew-cask
 | 
			
		||||
 | 
			
		||||
install_cleanup
 | 
			
		||||
    brew cask install alfred
 | 
			
		||||
    brew cask install arq
 | 
			
		||||
    brew cask install firefox
 | 
			
		||||
    brew cask install google-chrome
 | 
			
		||||
    brew cask install hipchat
 | 
			
		||||
    brew cask install iterm2
 | 
			
		||||
    brew cask install java
 | 
			
		||||
    brew cask install libreoffice
 | 
			
		||||
    brew cask install phpstorm
 | 
			
		||||
    brew cask install skype
 | 
			
		||||
    brew cask install slack
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if command -v apt >/dev/null 2>&1; then
 | 
			
		||||
 | 
			
		||||
    sudo -v
 | 
			
		||||
 | 
			
		||||
    sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
 | 
			
		||||
 | 
			
		||||
    # Add repositories
 | 
			
		||||
 | 
			
		||||
    ## Hipchat
 | 
			
		||||
    sudo sh -c 'echo "deb https://atlassian.artifactoryonline.com/atlassian/hipchat-apt-client $(lsb_release -c -s) main" > /etc/apt/sources.list.d/atlassian-hipchat4.list'
 | 
			
		||||
 | 
			
		||||
    ## Ondrej PHP PPA
 | 
			
		||||
    sudo add-apt-repository -y ppa:ondrej/php
 | 
			
		||||
 | 
			
		||||
    ## Docker
 | 
			
		||||
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 | 
			
		||||
    sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 | 
			
		||||
 | 
			
		||||
    ## Virtualbox
 | 
			
		||||
    curl -fsSL https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo apt-key add -
 | 
			
		||||
    sudo add-apt-repository -y "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"
 | 
			
		||||
 | 
			
		||||
    sudo apt update
 | 
			
		||||
 | 
			
		||||
    # Install apt packages
 | 
			
		||||
    sudo apt install -y \
 | 
			
		||||
        chromium-browser \
 | 
			
		||||
        dkms virtualbox-5.1 \
 | 
			
		||||
        dnsmasq \
 | 
			
		||||
        docker-ce \
 | 
			
		||||
        git \
 | 
			
		||||
        hipchat \
 | 
			
		||||
        htop \
 | 
			
		||||
        jq \
 | 
			
		||||
        linux-image-extra-$(uname -r) linux-image-extra-virtual \
 | 
			
		||||
        mysql-workbench \
 | 
			
		||||
        openjdk-9-jdk openjdk-8-jdk \
 | 
			
		||||
        scdaemon pcscd libccid \
 | 
			
		||||
        transmission \
 | 
			
		||||
        vim \
 | 
			
		||||
        vlc
 | 
			
		||||
 | 
			
		||||
    ## Docker Compose
 | 
			
		||||
    if [ ! -f /usr/local/bin/docker-compose ]; then
 | 
			
		||||
        DOCKER_COMPOSE_VERSION=1.16.1
 | 
			
		||||
        sudo curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
 | 
			
		||||
        sudo curl -L https://raw.githubusercontent.com/docker/compose/${DOCKER_COMPOSE_VERSION}/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    ## Vagrant
 | 
			
		||||
    if [ ! -f /usr/bin/vagrant ]; then
 | 
			
		||||
        sudo curl -L https://releases.hashicorp.com/vagrant/2.0.0/vagrant_2.0.0_x86_64.deb -o vagrant.deb && sudo dpkg -i vagrant.deb && rm -rf vagrant.deb
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
fi
 | 
			
		||||
 
 | 
			
		||||
@@ -38,5 +38,7 @@ brew install https://raw.github.com/nybblr/homebrew-dev/master/sack.rb
 | 
			
		||||
brew install python
 | 
			
		||||
sudo pip install fabric
 | 
			
		||||
 | 
			
		||||
brew install gist
 | 
			
		||||
 | 
			
		||||
# Remove outdated versions from the cellar
 | 
			
		||||
brew cleanup
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								sync.py
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								sync.py
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
#!/usr/bin/env python
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
Dotfiles syncronization.
 | 
			
		||||
@@ -47,15 +47,15 @@ def main():
 | 
			
		||||
			if is_link_to(dotfile, source):
 | 
			
		||||
				continue
 | 
			
		||||
 | 
			
		||||
			response = raw_input("Overwrite file `%s'? [y/N] " % dotfile)
 | 
			
		||||
			response = input("Overwrite file `%s'? [y/N] " % dotfile)
 | 
			
		||||
			if not response.lower().startswith('y'):
 | 
			
		||||
				print "Skipping `%s'..." % dotfile
 | 
			
		||||
				print("Skipping `%s'..." % dotfile)
 | 
			
		||||
				continue
 | 
			
		||||
 | 
			
		||||
			force_remove(dotfile)
 | 
			
		||||
 | 
			
		||||
		os.symlink(source, dotfile)
 | 
			
		||||
		print "%s => %s" % (dotfile, source)
 | 
			
		||||
		print("%s => %s" % (dotfile, source))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,8 @@ done
 | 
			
		||||
export LC_ALL=en_US.UTF-8
 | 
			
		||||
export LANG="en_US"
 | 
			
		||||
 | 
			
		||||
# Set the composer home.
 | 
			
		||||
export COMPOSER_HOME="$HOME/.composer"
 | 
			
		||||
 | 
			
		||||
# Prepend $PATH without duplicates
 | 
			
		||||
function _prepend_path() {
 | 
			
		||||
@@ -39,16 +41,18 @@ function _prepend_path() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Construct $PATH
 | 
			
		||||
PATH='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
 | 
			
		||||
[ -d /usr/texbin ] && _prepend_path "/usr/texbin"
 | 
			
		||||
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
 | 
			
		||||
[ -d /usr/local/sbin ] && _prepend_path "/usr/local/sbin"
 | 
			
		||||
[ -d /usr/local/bin ] && _prepend_path "/usr/local/bin"
 | 
			
		||||
[ -d /usr/local/share/npm/bin ] && _prepend_path "/usr/local/share/npm/bin"
 | 
			
		||||
[ -d /usr/local/opt/ruby/bin ] && _prepend_path "/usr/local/opt/ruby/bin"
 | 
			
		||||
[ -d /usr/local/share/python ] && _prepend_path "/usr/local/share/python"
 | 
			
		||||
command -v brew >/dev/null 2>&1 && _prepend_path "$(brew --prefix coreutils)/libexec/gnubin"
 | 
			
		||||
[ -d ~/dotfiles/bin ] && _prepend_path "$HOME/dotfiles/bin"
 | 
			
		||||
[ -d ~/bin ] && _prepend_path "$HOME/bin"
 | 
			
		||||
[ -f /usr/bin/npm ] && _prepend_path "./node_modules/.bin"      # Node.js
 | 
			
		||||
[ -d /usr/texbin ] && _prepend_path "/usr/texbin"               # LaTex
 | 
			
		||||
[ -d $HOME/.cargo/bin ] && _prepend_path "$HOME/.cargo/bin"     # Rust
 | 
			
		||||
command -v brew >/dev/null 2>&1 && _prepend_path "$(brew --prefix coreutils)/libexec/gnubin" # Homebrew
 | 
			
		||||
[ -d $HOME/.local/bin ] && _prepend_path "$HOME/.local/bin"     # Local bin
 | 
			
		||||
[ -d $HOME/bin ] && _prepend_path "$HOME/bin"                   # ~/bin
 | 
			
		||||
[ -d $HOME/dotfiles/bin ] && _prepend_path "$HOME/dotfiles/bin" # Dotfiles bin
 | 
			
		||||
[ -d "$COMPOSER_HOME/vendor/bin" ] && _prepend_path "$COMPOSER_HOME/vendor/bin" # PHP Composer
 | 
			
		||||
_prepend_path "./vendor/bin"
 | 
			
		||||
export PATH
 | 
			
		||||
 | 
			
		||||
# Colors
 | 
			
		||||
@@ -69,45 +73,22 @@ NOCOLOR="$(tput sgr0)"
 | 
			
		||||
export EDITOR=`which vim`
 | 
			
		||||
 | 
			
		||||
# Load prompt and aliases
 | 
			
		||||
for file in ~/dotfiles/includes/bash_{prompt,aliases,functions,git}.bash; do
 | 
			
		||||
for file in ~/dotfiles/includes/bash_*.bash; do
 | 
			
		||||
	[ -r "$file" ] && source "$file"
 | 
			
		||||
done
 | 
			
		||||
unset file
 | 
			
		||||
 | 
			
		||||
# If possible, add tab completion for many commands
 | 
			
		||||
[ -f /etc/bash_completion ] && source /etc/bash_completion
 | 
			
		||||
if [ `uname` == 'Darwin' ]; then
 | 
			
		||||
    export GOROOT="/usr/local/Cellar/go/1.3/libexec"
 | 
			
		||||
    export GOPATH=$HOME/go
 | 
			
		||||
 | 
			
		||||
# Bash completion (installed via Homebrew; source after `brew` is added to PATH)
 | 
			
		||||
command -v brew >/dev/null 2>&1 && [ -r "$(brew --prefix)/etc/bash_completion" ] && source "$(brew --prefix)/etc/bash_completion"
 | 
			
		||||
 | 
			
		||||
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
 | 
			
		||||
function _ssh_reload_autocomplete() {
 | 
			
		||||
	[ -e "~/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
 | 
			
		||||
}
 | 
			
		||||
_ssh_reload_autocomplete
 | 
			
		||||
 | 
			
		||||
# Grunt completion
 | 
			
		||||
command -v grunt >/dev/null 2>&1 && eval "$(grunt --completion=bash)"
 | 
			
		||||
 | 
			
		||||
# Tamia generator completion
 | 
			
		||||
function _tamia_autocomplete() {
 | 
			
		||||
	# List of subgenerators
 | 
			
		||||
	local available=$(for file in /usr/local/share/npm/lib/node_modules/generator-tamia/*/index.js; do echo $file | cut -d / -f 9; done)
 | 
			
		||||
	# The word fragment
 | 
			
		||||
	local word=${COMP_WORDS[COMP_CWORD]}
 | 
			
		||||
	# Don’t attempt to filter w/`grep` if `$word` is empty
 | 
			
		||||
	local filtered=$(if [ -z "$word" ]; then echo "$available"; else echo "$available" | grep $word; fi)
 | 
			
		||||
 
 | 
			
		||||
	COMPREPLY=($filtered)
 | 
			
		||||
}
 | 
			
		||||
command -v yo >/dev/null 2>&1 && complete -F _tamia_autocomplete tm
 | 
			
		||||
    launchctl setenv GOROOT $GOROOT
 | 
			
		||||
    launchctl setenv GOPATH $GOPATH
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Tell ls to be colourful
 | 
			
		||||
export CLICOLOR=1
 | 
			
		||||
 | 
			
		||||
# Tell grep to highlight matches
 | 
			
		||||
export GREP_OPTIONS='--color=auto'
 | 
			
		||||
 | 
			
		||||
# Make less the default pager, and specify some useful defaults.
 | 
			
		||||
less_options=(
 | 
			
		||||
	# If the entire text fits on one screen, just show it and quit. (Be more
 | 
			
		||||
@@ -138,3 +119,8 @@ export PAGER='less'
 | 
			
		||||
 | 
			
		||||
# Load extra (private) settings
 | 
			
		||||
[ -f ~/.bashlocal ] && source ~/.bashlocal
 | 
			
		||||
 | 
			
		||||
# Force a green prompt
 | 
			
		||||
true
 | 
			
		||||
 | 
			
		||||
export PATH="$HOME/.cargo/bin:$PATH"
 | 
			
		||||
 
 | 
			
		||||
@@ -6,39 +6,53 @@
 | 
			
		||||
    frag = white
 | 
			
		||||
    old = red bold
 | 
			
		||||
    new = green bold
 | 
			
		||||
 | 
			
		||||
[help]
 | 
			
		||||
    autocorrect = 1
 | 
			
		||||
 | 
			
		||||
[core]
 | 
			
		||||
    editor = vim
 | 
			
		||||
    # Force vim in foreground mode.
 | 
			
		||||
    editor = vim -f
 | 
			
		||||
    # http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
 | 
			
		||||
    # If doesn't work, try: pager = less -+$LESS -FRX
 | 
			
		||||
    pager = less -r
 | 
			
		||||
    pager = diff-highlight | less -RFX
 | 
			
		||||
#    pager = less -r
 | 
			
		||||
    autocrlf = false
 | 
			
		||||
    safecrlf = false
 | 
			
		||||
    mergeoptions = --no-edit
 | 
			
		||||
    excludesfile = ~/.gitignore
 | 
			
		||||
 | 
			
		||||
[alias]
 | 
			
		||||
    a = add
 | 
			
		||||
    ua = reset HEAD
 | 
			
		||||
    ap = add --patch
 | 
			
		||||
    b = branch
 | 
			
		||||
    c = commit --verbose
 | 
			
		||||
    ca = commit -a --verbose
 | 
			
		||||
    cm = commit -m --verbose
 | 
			
		||||
    cam = commit -am --verbose
 | 
			
		||||
    c = commit --verbose --signoff
 | 
			
		||||
    cm = commit --verbose --signoff --message
 | 
			
		||||
    co = checkout
 | 
			
		||||
    d = diff --color-words
 | 
			
		||||
    s = status -sb
 | 
			
		||||
    d = diff
 | 
			
		||||
    ds = diff --staged
 | 
			
		||||
    l = log --graph --pretty=format:'%C(magenta)%h%C(blue)%d%Creset %s %C(blue bold)- %an, %ar%Creset'
 | 
			
		||||
    ll = log --stat --abbrev-commit
 | 
			
		||||
    conflicts = diff --name-only --diff-filter=U
 | 
			
		||||
    r = rebase
 | 
			
		||||
    s = status --short --branch
 | 
			
		||||
    ua = reset HEAD
 | 
			
		||||
    commerge = commit --no-edit
 | 
			
		||||
    conflicts = diff --name-only --diff-filter=U
 | 
			
		||||
[push]
 | 
			
		||||
    default = current
 | 
			
		||||
    default = upstream
 | 
			
		||||
 | 
			
		||||
# Any GitHub repo with my username should be checked out r/w by default
 | 
			
		||||
# http://rentzsch.tumblr.com/post/564806957/public-but-hackable-git-submodules
 | 
			
		||||
[url "git@github.com:jacobkiers/"]
 | 
			
		||||
    insteadOf = "git://github.com/jacobkiers/"
 | 
			
		||||
 | 
			
		||||
[url "git@bitbucket.org:jacobkiers/"]
 | 
			
		||||
    insteadOf = "https://bitbucket.org/jacobkiers/"
 | 
			
		||||
 | 
			
		||||
# URL shorthands
 | 
			
		||||
 | 
			
		||||
[url "git@bitbucket.org:"]
 | 
			
		||||
    insteadOf = "bb:"
 | 
			
		||||
[url "git@github.com:"]
 | 
			
		||||
    insteadOf = "gh:"
 | 
			
		||||
    pushInsteadOf = "github:"
 | 
			
		||||
@@ -57,11 +71,16 @@
 | 
			
		||||
 | 
			
		||||
# DiffMerge
 | 
			
		||||
[merge]
 | 
			
		||||
    ff = no
 | 
			
		||||
    commit = no
 | 
			
		||||
    tool = diffmerge
 | 
			
		||||
[mergetool "diffmerge"]
 | 
			
		||||
    cmd = diffmerge --merge --result=$MERGED $LOCAL $BASE $REMOTE
 | 
			
		||||
    trustExitCode = true
 | 
			
		||||
[diff]
 | 
			
		||||
    algorithm = minimal
 | 
			
		||||
    compationHeuristic = true
 | 
			
		||||
    renames = true
 | 
			
		||||
    tool = diffmerge
 | 
			
		||||
[difftool "diffmerge"]
 | 
			
		||||
    cmd = diffmerge $LOCAL $REMOTE
 | 
			
		||||
@@ -72,3 +91,11 @@
 | 
			
		||||
# git config -f ~/.gitlocal user.name "Jacob Kiers"
 | 
			
		||||
[include]
 | 
			
		||||
    path = .gitlocal
 | 
			
		||||
 | 
			
		||||
[fetch]
 | 
			
		||||
    prune = true
 | 
			
		||||
 | 
			
		||||
[init]
 | 
			
		||||
    templatedir = ~/dotfiles/resources/git-template
 | 
			
		||||
[pull]
 | 
			
		||||
	ff = yes
 | 
			
		||||
 
 | 
			
		||||
@@ -22,3 +22,4 @@ bower_components
 | 
			
		||||
 | 
			
		||||
# IDEs stuff
 | 
			
		||||
.idea
 | 
			
		||||
atlassian-ide-plugin.xml
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										44
									
								
								update.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								update.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
pushd "$HOME/dotfiles" > /dev/null || exit 1;
 | 
			
		||||
 | 
			
		||||
CURRENT_HASH=`md5sum update.sh | awk '{ print $1 }'`
 | 
			
		||||
 | 
			
		||||
echo -n "Pulling changes... "
 | 
			
		||||
git pull
 | 
			
		||||
 | 
			
		||||
NEW_HASH=`md5sum update.sh | awk '{ print $1 }'`
 | 
			
		||||
if [ "$CURRENT_HASH" != "$NEW_HASH" ]
 | 
			
		||||
then
 | 
			
		||||
    echo "The update script has changed."
 | 
			
		||||
    ./update
 | 
			
		||||
    exit
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo "Syncing..."
 | 
			
		||||
./sync.py
 | 
			
		||||
 | 
			
		||||
source "$HOME/.bashrc"
 | 
			
		||||
 | 
			
		||||
if [ ! -f bin/composer ]
 | 
			
		||||
then
 | 
			
		||||
    echo "Installing composer..."
 | 
			
		||||
    wget https://getcomposer.org/composer.phar -O bin/composer
 | 
			
		||||
    chmod +x bin/composer
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo -n "Updating composer and dependencies... "
 | 
			
		||||
bin/composer --quiet self-update
 | 
			
		||||
bin/composer --quiet global require \
 | 
			
		||||
    fabpot/php-cs-fixer \
 | 
			
		||||
    phpmd/phpmd \
 | 
			
		||||
    phpunit/phpunit \
 | 
			
		||||
    squizlabs/php_codesniffer
 | 
			
		||||
 | 
			
		||||
echo "Done."
 | 
			
		||||
 | 
			
		||||
if [ ! -L resources/git-template/hooks ]
 | 
			
		||||
then
 | 
			
		||||
    ln -s $HOME/dotfiles/resources/git-hooks resources/git-template/hooks
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
popd > /dev/null
 | 
			
		||||
		Reference in New Issue
	
	Block a user