1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-08 04:04:22 +02:00
lazygit/get_branches.sh

18 lines
494 B
Bash
Raw Normal View History

2018-05-20 11:00:34 +02:00
#!/bin/bash
set -e
git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD | {
seen=":"
git_dir="$(git rev-parse --git-dir)"
while read line; do
date="${line%%|*}"
branch="${line##* }"
if ! [[ $seen == *:"${branch}":* ]]; then
seen="${seen}${branch}:"
if [ -f "${git_dir}/refs/heads/${branch}" ]; then
printf "%s\t%s\n" "$date" "$branch"
fi
fi
done
} | sed 's/ days /d /g' | sed 's/ weeks /w /g' | sed 's/ago//g' | tr -d ' '