Geeking Out

Git Automation

If you use Git a lot and find yourself doing the same things over an over, then a script can help save time and typing. Feel free to copy/paste my code to automate certain repetitive tasks like managing stashes and committing and merging. I prefix my Git commands with 'gt' and then some kind of shorthand for a command.

Stashes:

Shortcuts defined in your shell profile (.bash_profile, .bashrc, etc)"
alias gtstshls='git stash list'
alias gtstshaply=/YOUR/PATH/TO/THIS/FILE/gitApplyStash.sh

Apply a stash with 'gtstshaply n' where n is a stash number:

gitApplyStash.sh

#!/bin/bash

##########
# Author: Clif Jackson
# Email: code@clifjackson.net
# https://www.gnu.org/licenses/gpl.txt
##########

if [ "$#" -ne 1 ]; then
    echo "You must supply a stash index "
    exit
fi

echo "Are you sure you want to apply stash@{$1}? [y/n] "
while read -r -n 1 -s answer; do
    if [[ $answer != "y" ]]; then
        echo "Done "
        exit
    else
        git stash apply stash@{$1}
        git stash list
        break
    fi
done

Mac OS X Mods

Show hidden files in the Finder (all versions):

  • Navigate to ~/Library/Preferences/com.apple.finder.plist
  • open in a text editor (no admin rights needed!).
  • add the two yellow lines below and then reboot your computer (you may be able to just log out & log in again):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>AppleShowAllFiles</key>
    <string>true</string>
    <key>ComputerViewSettings</key>
    <dict>...

Web Stuff

A cross-platform way to avoid phone numbers, email addresses, dates, etc from displaying as links:

Break up the pattern with <span> tags.

raw numbers: 123-456-7890
mark up: <span>1</span>2<span>3-</span>45<span>6-7</span>8<span>90</span>
rendered: 123-456-7890

Of course, you can also use the iOS specific way of using a <meta> tag:

<meta name="format-detection" content="telephone=no">

clifjackson.net :: web :: geeking out