Skip to content

Instantly share code, notes, and snippets.

View ZevEisenberg's full-sized avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
@ZevEisenberg
ZevEisenberg / AndroidScreenRecording.sh
Last active October 14, 2015 14:17
Functions to take a screen video recording or screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
function androidScreenshot
{
# only do this if there is a device connected
adb shell exit 2>/dev/null
if [[ $? == 0 ]]; then
# Example filename: ~/Desktop/Android Screen 2013-09-11 12.32.16 PM.png
# perl line ending hacks from http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
dateString=`date +"%Y-%m-%d at %I.%M.%S %p"`
fileName="Android Screen $dateString.png"
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/$fileName
@ZevEisenberg
ZevEisenberg / gist:9808986
Created March 27, 2014 14:39
Function to take a screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
function androidScreenshot
{
# only do this if there is a device connected
adb shell exit 2>/dev/null
if [[ $? == 0 ]]; then
# Example filename: ~/Desktop/Android Screen 2013-09-11 12.32.16 PM.png
# perl line ending hacks from http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
dateString=`date +"%Y-%m-%d at %I.%M.%S %p"`
fileName="Android Screen $dateString.png"
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/$fileName
@ZevEisenberg
ZevEisenberg / moveAssetImages.sh
Created February 25, 2014 05:17
Shell script to move a folder of correctly-named image files into their respective .xcassets subfolders
#!/bin/sh
function moveAssetImages
{
usage="usage: moveAssetImages /path/to/folderOfImages /path/to/Images.xcassets"
sourceDir=$1
assetsDir=$2
if [ $# != 2 ]; then
@ZevEisenberg
ZevEisenberg / fixTerminal.sh
Created January 20, 2014 16:56
Function to set Control-Tab and Control-Shift-Tab for Select Next Tab and Select Previous Tab in Terminal.app
#!/bin/sh
# First, a function to safely add custom menu item entries to com.apple.universalaccess.plist,
# since duplicate entries in com.apple.custommenu.apps causes a crash when you open
# System Preferences and go to Keyboard -> Shortcusts
function addCustomMenuEntryIfNeeded
{
if [[ $# == 0 || $# > 1 ]]; then
echo "usage: addCustomMenuEntryIfNeeded com.company.appname"
return 1
@ZevEisenberg
ZevEisenberg / glastcommit.sh
Last active December 24, 2015 12:59
Copies full log of the last git commit to the clipboard (and displays it, too)
# this is useful for lots of git-related functions
alias returnIfNotGitRepo='if isGitRepo; then; ; else echo "No repositories here."; return 1; fi'
function glastcommit
{
returnIfNotGitRepo
git show --name-only
git show --name-only | pbcopy
}
@ZevEisenberg
ZevEisenberg / fixXcode.sh
Last active January 6, 2024 07:31
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
function fixXcode
{
pushd > /dev/null
cd
xcodepath=`xcode-select --print-path`/..
destination=$xcodepath/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
shouldRelaunchXcode=false
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then