Skip to content

Instantly share code, notes, and snippets.

@bavis-m
bavis-m / pushmod.sh
Created May 20, 2018 20:00
bash function for pushd-ing the directory of the Nth submodule in a git project
#!/usr/bin/env bash
pushmod() {
local root=`git rev-parse --show-toplevel`
local dir=`git config --file "$root/.gitmodules" --get-regexp path | cut -d" " -f2- | sed "\\\$q;${1:-1}q;d"`
pushd "$root/$dir"
}