View defer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define macro_var(name) name##__LINE__ | |
#define defer(start, end) for ( \ | |
int macro_var(_i_) = (start, 0); \ | |
!macro_var(_i_); \ | |
(macro_var(_i_) += 1), end) \ | |
/** | |
Example usage: | |
View git_show_bash.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# allows user to git show by the number the commit appears in git log | |
# 1 is the first commit, 2 is the second, etc... | |
git_show() { | |
re='^[0-9]+$' | |
if ! [[ $1 =~ $re ]]; then | |
return | |
fi | |
sha="$(git log -$1 --format="%H")" | |
shaSplit=(${sha//\n/ }) | |
git show ${shaSplit[$(($1 - 1))]} |