helm/shell/sk/bin/sk-git-sha

12 lines
391 B
Plaintext
Raw Normal View History

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