Skip to content
Browse files

Grab new binfiles from hashrocket's repo.

  • Loading branch information...
1 parent 8e9bbbe commit 203ff6bbe42ce35bf597f0f3063c607512c3e80b @judy committed Jan 17, 2014
Showing with 113 additions and 67 deletions.
  1. +19 −0 bin/file_list.sh
  2. +0 −59 bin/hlink
  3. +0 −8 bin/hr
  4. +48 −0 bin/install
  5. +30 −0 bin/uninstall
  6. +16 −0 bin/upgrade
View
19 bin/file_list.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+set -e
+
+dir=$PWD
+files=
+
+manualfile="$dir/FILES"
+
+if [ -f $manualfile ]; then
+ files="$(cat $manualfile)"
+else
+ # Get list of files to link
+ includes=".vim .zsh"
+ excludes=".gitignore"
+ base="$(find . -maxdepth 1 -name '.*' -not -name '.*.local' -type f | sed 's#^\./##' | grep -vF $excludes)"
+ files="$base $includes"
+fi
+
+echo $files
View
59 bin/hlink
@@ -1,59 +0,0 @@
-#!/usr/bin/env ruby
-require 'fileutils'
-
-def cwd
- @cwd ||= File.expand_path(File.dirname(__FILE__))
-end
-
-def root
- File.dirname(cwd)
-end
-
-def home
- @home ||= File.expand_path('~')
-end
-
-def destination(file,sub_directory)
- File.join(*[home, sub_directory, File.basename(file)].compact)
-end
-
-def install(file,sub_directory=nil)
- if system("ln -nsf #{root}/#{file} #{home}/#{file}")
- print "successfully installed "
- else
- print "failed to install "
- end
- puts file
-end
-
-def uninstall(file,sub_directory=nil)
- file = File.join(home, file)
- return puts "no file at #{file}" unless File.exist?(file)
- if File.symlink?(file)
- File.unlink(file)
- puts "removed symlink at #{file}"
- else
- puts "could not remove non-symlink at #{file}"
- end
-end
-
-def uninstall?
- ARGV.include?('-u')
-end
-
-if ARGV.include?('-h')
- script = File.basename(__FILE__)
- puts %[
- "#{script}" symlinks the files in dotmatrix into your home directory.
- options:
- -h Get this help
- -u Remove symlinks to files in dotmatrix
- ]
- exit 0
-end
-
-FileUtils.mkdir_p(File.join(home,'bin'))
-(Dir.entries(root) - %w(bin . .. .git) + ['bin/hr']).each do |file|
- next if file =~ /~$/
- uninstall? ? uninstall(file) : install(file)
-end
View
8 bin/hr
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-command="$1"
-shift
-
-case "$command" in
- *) "$command" "$@" ;;
-esac
View
48 bin/install
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+set -e
+
+dir=$PWD
+if [[ ! "$dir/bin/install" -ef "$0" ]]; then
+ echo "Please run 'bin/install' from dotmatrix root folder"
+ exit 1
+fi
+
+# Ensure presence of directory for vim undo files
+undo_dir_path="Library/Vim/undo"
+if [ ! -d $HOME/$undo_dir_path ]; then
+ echo -n "Creating"
+ mkdir -p $HOME/$undo_dir_path
+else
+ echo -n "Skipping"
+fi
+echo " ~/$undo_dir_path"
+
+# Copy *.local files
+for dotfile in .*.local ; do
+ dotmatrix_path=$dir/$dotfile
+ path="$HOME/$dotfile"
+
+ if [ ! -e $path ]; then
+ echo "Copying $dotfile to $path"
+ cp $dotmatrix_path $path
+ else
+ echo -e "Skipping $dotfile \talready exists"
+ fi
+done
+
+# Symlink dotfiles
+files="$(./bin/file_list.sh)"
+
+for dotfile in $files; do
+ dotmatrix_path="$dir/$dotfile"
+ path="$HOME/$dotfile"
+
+ [ -e $dotmatrix_path ] || continue
+
+ if [ ! -L $path ]; then
+ echo "Symlinking $dotfile to $path"
+ ln -nfs $dotmatrix_path $path
+ else
+ echo -e "Skipping $dotfile \talready exists"
+ fi
+done
View
30 bin/uninstall
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -e
+
+dir=$PWD
+if [[ ! "$dir/bin/uninstall" -ef "$0" ]]; then
+ echo "Please run 'bin/uninstall' from dotmatrix root folder"
+ exit 1
+fi
+
+skip_file() {
+ echo -e "Skipping $1 \t$2"
+}
+
+files="$(./bin/file_list.sh)"
+
+for dotfile in $files; do
+ dotmatrix_path="$dir/$dotfile"
+ path="$HOME/$dotfile"
+
+ if [ -L $path ]; then # Symlink?
+ if [ $dotmatrix_path = "$(readlink $path)" ]; then # Symlinked here?
+ echo "Removing $path"
+ unlink $path
+ else
+ skip_file $dotfile "exists, but is not from dotmatrix"
+ fi
+ else
+ skip_file $dotfile "not found or is not a symlink"
+ fi
+done
View
16 bin/upgrade
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+set -e
+
+if [[ ! "$PWD/bin/upgrade" -ef "$0" ]]; then
+ echo "Please run 'bin/upgrade' from dotmatrix root folder"
+ exit 1
+fi
+
+if [ -n "$(git status --porcelain)" ]; then
+ echo "ERROR: You have a dirty working copy."
+ echo "Commit or clean any changes, and run bin/upgrade again."
+ exit 1
+fi
+
+git pull --rebase
+./bin/install

0 comments on commit 203ff6b

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