Skip to content

Instantly share code, notes, and snippets.

View ejmr's full-sized avatar

Eric James Michael Ritz ejmr

  • United States
View GitHub Profile
@ejmr
ejmr / for-each-subdir
Created August 17, 2018 23:01
Perform Arbitrary Commands on Immediate Subdirectories
#!/bin/sh
#
# for-each-subdir
# ===============
#
# ## SYNOPSIS
#
# $ for-each-subdir [FLAGS]
#
# ## DESCRIPTION
@ejmr
ejmr / git-ls-github-repos.sh
Created May 15, 2018 17:55
Display URLs for all public GitHub repositories of a given user
#!/bin/sh
#
# git-ls-github-repos(1) - list a user's GitHub repositories
# ==========================================================
#
# ## SYNOPSIS
#
# `git-ls-github-repos` <user>
#
# ## REQUIREMENTS
@ejmr
ejmr / git-branch-show-description.sh
Last active May 29, 2022 07:41
Show the Description for the Current Branch
#!/bin/bash
#
# You can use `git branch --edit-description` to write a description
# for a branch, but Git provides no simple command to display that
# description. The "easiest" way to see it is via `git config --get
# branch.BRANCH_NAME.description`.
#
# This script automates that process and is meant to be used as
# a Git alias to provide a shorter command for showing the
# description of the current branch.
@ejmr
ejmr / gist:bddbfabc58b20524b3ce
Created November 15, 2015 14:09
Fish Shell Function for Compiling PHP 7
function build-php --description="Build PHP from source in the current directory"
sh configure --prefix=/opt/php \
--with-openssl \
--enable-soap \
--enable-sockets \
--enable-intl \
--enable-ftp \
--enable-bcmath \
--enable-calendar \
--enable-zip \
@ejmr
ejmr / gist:453edc19dd596e472e90
Created November 15, 2015 13:47
Update Git Submodules After Each Merge or Pull
#!/bin/sh
#
# This simple shell script is a Git hook that will automatically
# update all submodules any time you perform a merge or pull.
# This can be useful because you can do things like...
#
# $ git checkout master && git pull
#
# ...without having to remember to potentially update any
# submodules in the repository.
@ejmr
ejmr / run-cp-stderr.fish
Created October 19, 2015 04:12
Fish Shell Script to Help Search for Error Messages Online
# This function runs a command while copying standard error to a
# temporary file. If the command has a non-zero exit code then the
# function copies the last line of standard error to the clipboard.
# This makes it easy to switch over to my browser and do a search for
# that error message.
function run-cp-stderr --description="Run a command copying the tail of STDERR to the clipboard"
set --local ERROR_FILE (mktemp --suffix=".fish-command.log" --tmpdir="/tmp")
if not eval $argv ^$ERROR_FILE
tail --lines=1 "$ERROR_FILE" | xclip -in -selection "clipboard"
@ejmr
ejmr / git-pick-branch.sh
Created September 9, 2015 08:05
Checkout a Git Branch Using Fuzzy-Selection
#!/bin/sh
#
# git pick-branch
#
# This command checks out a branch, using the commnad `pick` to
# provide fuzzy-selection of the branch names.
#
# https://github.com/thoughtbot/pick
#
######################################################################
@ejmr
ejmr / list-makefile-targets
Created July 1, 2015 12:50
List all targets of a Makefile from the terminal
#!/bin/sh
#
# Running this script in a directory with a Makefile will print the
# targets in that Makefile, e.g.
#
# $ list-makefile-targets
# all
# clean
# docs
# install