helm/shell/sk/bin/sk-git-sha
2018-03-23 15:29:50 -04:00

12 lines
391 B
Bash
Executable file

#!/usr/bin/env bash
# Retrieves a git commit's SHA, useful for a variety of git commands.
#
# Examples:
# + git checkout `sk-git-sha`
# + git commit --fixup `sk-git-sha`
commits=$(git log --color=always --abbrev-commit --reverse --format="%C(auto)%h%d %s %C(black)%C(bold)%cr") &&
commit=$(echo "$commits" | sk --tac --no-sort -e --ansi) &&
echo -n $(echo "$commit" | sed "s/ .*//")