Skip to content

Instantly share code, notes, and snippets.

@trovster
Created May 7, 2019 10:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save trovster/1a1d8616bf7eadb7603571b93c762ac7 to your computer and use it in GitHub Desktop.
ZSH Helpers for git
# List with git branch next to them (requires gawk). (brew install gawk)
ls-git () {
ls -alF "$@" | gawk '{
match($0,/^(\S+\s+){8}(.+)$/, f);
b = "";
c = "git -C \""f[2]"\" branch 2>/dev/null";
while ((c|getline g) > 0) {
if (match(g,/^\* (.+)$/,a)) {
b="("a[1]")"
}
};
close(c);
print $0,b
}';
}
# Update all repositories (inside ~/Sites)
alias git-refresh="find ~/Sites -maxdepth 1 -type d -print -execdir git -C {} pull \;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment