Skip to content

Instantly share code, notes, and snippets.

View KeyboardCowboy's full-sized avatar

Chris Albrecht KeyboardCowboy

  • Lullabot
  • Golden, CO
  • 22:38 (UTC -06:00)
View GitHub Profile
@KeyboardCowboy
KeyboardCowboy / commit-msg
Created April 21, 2015 23:10
Blastr Git Commit Message Hook for Jira Comments
#!/bin/bash
# INSTRUCTIONS
#
# 1. Copy .git/hooks/commit-msg.sample to .git/hooks/commit-msg
# 2. Replace the contents of commit-msg with this file
#
# Automatically add ticket numbers to commit messages using branch names.
#
# Branches should be in the format [username]-[issue #]-[short-desc]
#
@KeyboardCowboy
KeyboardCowboy / aliases.drushrc.php
Last active December 14, 2015 15:49
Drush auto-alias script. This script, when placed in your /etc/drush folder will scan your webroot and auto-detect Drupal installations, both standalone and multisite, and create aliases for each site. It is not complete yet. The grouping still needs a little work, but otherwise gets you off the ground.
<?php
/**
* @file
* Build a dynamic list of drush aliases by identifying Drupal directories.
*
* The script will scan your webroot for Drupal directories. Place this in
* /etc/drush/aliases.drushrc.php
*
* @param $root
* The absolute path to your webroot.
@KeyboardCowboy
KeyboardCowboy / cdd
Last active December 14, 2015 15:49
Quick directory traversal with Drush Aliases and Bash.Do you use drush aliases? Drip this little snippet into your .bash_profile or .bash_rc and start saving bucketloads of time.
###
# Quick directory change for drush.
# While inside a Drupal site, simply cdd to a module or theme by name.
# Add an alias to quickly jump to that site's root or any theme or module within that site
#
# EX.
# $ cdd zen (takes you to zen theme within current Drupal site)
# $ cdd @mysite (takes to you mysite root)
# $ cdd @mysite zen (takes you to zen theme in mysite from anywhere on the server)
##
@KeyboardCowboy
KeyboardCowboy / commit-msg
Last active December 15, 2015 19:19
Automatically add ticket numbers to GIT commit messages using branch descriptions and GIT hooks.
#!/bin/bash
#
# Automatically add ticket numbers to commit messages using branch descriptions.
# Place this file in .git/hooks/commit-msg
#
# Add a description to your branch:
# git branch --edit-description [branch-name]
#
# Mark your ticket numbers anywhere in the description using the following
# syntax:
@KeyboardCowboy
KeyboardCowboy / AwesomeCode.class.php
Last active April 25, 2016 19:24
Drupal module class.
<?php
/**
* @file
* Module class for the AwesomeCode module.
*/
/**
* Class AwesomeCode.
*
* Container class for any custom functionality in the Awesome Code module.
@KeyboardCowboy
KeyboardCowboy / README.md
Last active April 27, 2016 16:30
Local Drush Environment File

Add these files to your ~/.drush directory or your Drupal project.

@KeyboardCowboy
KeyboardCowboy / .gitignore
Last active August 5, 2016 16:44
Keep selected Drupal modules out of PROD automatically with Drush.
# Create a safe space for dangerous modules.
/sites/*/modules/ignored/
/docroot/sites/*/modules/ignored/
@KeyboardCowboy
KeyboardCowboy / crontab
Created February 20, 2017 00:14
Have Your Mac Tell You Inspirational Quotes
# Say a quote every hour on the half hour.
30 * * * * /path/to/quotes.sh
@KeyboardCowboy
KeyboardCowboy / gitco.sh
Last active February 28, 2017 19:41
Shortcut to checkout a feature branch from a ticket number.
#!/usr/bin/env bash
#
# Shortcut to checkout a feature branch from a ticket number.
KEY=-1
SEARCH=$1
# Require a parameter.
if [[ -z "$SEARCH" ]]; then
echo "What are you searching for?"
@KeyboardCowboy
KeyboardCowboy / rename.sh
Last active April 5, 2017 18:10
Bulk Rename Files
#!/bin/bash
# File: rename
# Author: Chris Albrecht (chris at lullabot dot com)
#
# Bulk renaming of files.
FROM=$1
TO=$2
FILTER=$3