Skip to content

Instantly share code, notes, and snippets.

View leocencetti's full-sized avatar

Leonardo Cencetti leocencetti

View GitHub Profile
@leocencetti
leocencetti / git-amendabot
Last active July 9, 2024 08:19
git-amendabot
#!/usr/bin/env bash
set -eu
ROOT=$(pwd)
BRANCH=""
WORKTREE=""
match_branch() {
echo ">>> Looking up branch for PR $1..."
BRANCH=$(gh pr view --json headRefName --jq .headRefName $1)
@leocencetti
leocencetti / git-submodule-status
Last active July 20, 2023 13:00
git-submodule-status
#!/usr/bin/env bash
## constants ##
readonly USE_ANSI_COLOR=$( ([[ "$GBS_USE_ANSI_COLOR" =~ ^[01]$ ]] && echo -n "$GBS_USE_ANSI_COLOR") ||
([[ "$CFG_USE_ANSI_COLOR" =~ ^[01]$ ]] && echo -n "$CFG_USE_ANSI_COLOR") ||
echo -n '1')
readonly CBLUE=$( (($USE_ANSI_COLOR)) && echo '\033[1;34m')
readonly CTHINBLUE=$( (($USE_ANSI_COLOR)) && echo '\e[0;34m')
readonly CEND=$( (($USE_ANSI_COLOR)) && echo '\033[0m')
[alias]
co = checkout
br = branch
ci = commit
st = status
last = log -1
glog = log --graph --abbrev-commit --pretty=format:'%C(yellow)%h %C(blue)[%G?] %C(green)(%cr)%C(reset) %s'
olog = log --color --abbrev-commit --pretty=format:'%C(yellow)%h %C(blue)[%G?] %C(green)(%cr)%C(reset) %s'
tlog = log --color --abbrev-commit --pretty=format:'%ct %H'
unstage = restore --staged