Created
October 29, 2019 21:19
-
-
Save nvahalik/36108d4b892b6f66982537235f9cf462 to your computer and use it in GitHub Desktop.
git-split-commit
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
STAGED_CHANGES=`git status -s --untracked=no --porcelain | grep -v '^[\s\?]' | wc -l` | |
if [ "$STAGED_CHANGES" -eq 0 ]; then | |
echo "Nothing to commit. Quitting." | |
exit; | |
fi; | |
if [ "$TMUX" == "" ]; then | |
SESS="sc$$" | |
tmux new-session -d -s "$SESS" 'exec git diff --cached' | |
tmux rename-window -t "$SESS" 'Diff' | |
tmux select-window -t "$SESS":0 | |
tmux split-window -t "$SESS" -h 'exec git commit' | |
tmux send-keys -t "$SESS:0" -l 1G | |
tmux send-keys -t "$SESS:0" -l i | |
tmux set-hook -t "$SESS" pane-exited 'kill-session -t $SESS' | |
tmux -2 attach-session -t $SESS | |
else | |
tmux split-window -t "$TMUX_PANE" -h 'exec git commit' | |
tmux send-keys -l 1G | |
tmux send-keys -l i | |
tmux set-hook pane-exited 'send-keys -t $TMUX_PANE q' | |
git diff --cached | |
fi; | |
git --no-pager log -n 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment