Skip to content

Commit

Permalink
Move scripts to bin directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Dec 14, 2018
1 parent 33d60c7 commit 2caf39a
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
13 changes: 13 additions & 0 deletions bin/git-commit-each
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Commit all modified files in commits with one modified file per commit
for FILENAME in $(git ls-files --modified --others)
do
MESSAGE="$(echo "$FILENAME" | sed -e 's|^Library/Homebrew/||' \
-e 's|^Formula/||' \
-e 's|^Casks/||' \
-e 's/\.rb//' \
-e 's/$/: /')"
git add "$FILENAME"
git commit "$FILENAME" --message="${MESSAGE}${*}"
done
24 changes: 24 additions & 0 deletions bin/git-gc-global
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
# Garbage collect all Git repositories under the current directory.

CURRENT=$PWD
# Set to newline to loop over find output correctly on spaced paths.
IFS="
"

echorun() {
echo + "$@"
"$@"
}

find -L "$CURRENT" -name .git -print0 | while read -d '' -r SCM
do
DIRECTORY="$(dirname "$SCM")"
cd "$DIRECTORY" || continue
echo "== Garbage collecting $(basename "$DIRECTORY")"
if [ -d .git ]
then
echorun git gc --aggressive
fi
echo
done
32 changes: 32 additions & 0 deletions bin/rbenv-sync-homebrew-rubies
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby

require "pathname"
require "fileutils"

@rbenv_versions = Pathname("#{ENV["HOME"]}/.rbenv/versions")
homebrew_ruby_versions = Pathname.glob("/usr/local/Cellar/ruby")
homebrew_ruby_versions += Pathname.glob("/usr/local/Cellar/ruby@*")

def link_rbenv_version_without_revision(version)
basename_without_revision = version.basename
.to_s
.gsub(/_\d+$/, "")
FileUtils.ln_sf version, @rbenv_versions / basename_without_revision
end

def gem_like_version(version)
Gem::Version.new(version.basename
.to_s
.tr("_", "."))
end

@rbenv_versions.mkpath

homebrew_ruby_versions.flat_map(&:children)
.sort_by(&method(:gem_like_version))
.each(&method(:link_rbenv_version_without_revision))

@rbenv_versions.children
.select(&:symlink?)
.reject(&:exist?)
.each { |path| FileUtils.rm_f path }
40 changes: 40 additions & 0 deletions bin/scm-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
# Update all Git and Subversion repositories under the current directory.

CURRENT=$PWD
# Set to newline to loop over find output correctly on spaced paths.
IFS="
"

echorun() {
echo + "$@"
"$@"
}

find -L "$CURRENT" \( -name .git -or -name .svn \) -print0 | while read -d '' -r SCM
do
DIRECTORY="$(dirname "$SCM")"
cd "$DIRECTORY" || continue
if [ -d ../.svn ] || echo "$DIRECTORY" | grep -q "vendor/ruby"
then
continue
fi
echo "== Updating $(basename "$DIRECTORY")"
if [ -d .git/svn ]
then
echorun git svn fetch
echorun git svn rebase
elif [ -d .git ]
then
echorun git fetch --all
if [ -n "$(git remote -v)" ]; then
echorun git checkout --quiet master
echorun git merge --no-edit --ff-only origin/master
git branch --merged | grep -v '\*' | xargs -n 1 git branch -d
fi
elif [ -d .svn ]
then
echorun svn update
fi
echo
done
3 changes: 2 additions & 1 deletion shrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ add_to_path_end "/Applications/Fork.app/Contents/Resources"
add_to_path_end "/Applications/TextMate.app/Contents/Resources"
add_to_path_end "/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
add_to_path_end "/data/github/shell/bin"
add_to_path_end "$HOME/.dotfiles/bin"
add_to_path_start "/usr/local/bin"
add_to_path_start "/usr/local/sbin"
add_to_path_start "$HOME/Homebrew/bin"
Expand Down Expand Up @@ -164,7 +165,7 @@ then
# Old default Curl is broken for Git on Leopard.
[ "$OSTYPE" = "darwin9.0" ] && export GIT_SSL_NO_VERIFY=1

rbenv-sync-homebrew-rubies.rb
rbenv-sync-homebrew-rubies
elif [ "$LINUX" ]
then
quiet_which keychain && eval "$(keychain -q --eval --agents ssh id_rsa)"
Expand Down

0 comments on commit 2caf39a

Please sign in to comment.