~wrm/dotfiles

ref: 123b158daa220a00fac6f19c375ef16b91a168cc dotfiles/.config/shell/git-aliases.sh -rwxr-xr-x 649 bytes
123b158d — +wrm misc: Apply numerous minor changes 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

# Writes useful git aliases to stdout.

set -- 'g' 'git' 'g~' 'git\ --git-dir="$HOME\/git\/dotfiles\/"\ --work-tree="$HOME"'

subcommands="
s status
a add
c commit
r rebase
d diff
dt difftool

ch checkout
b branch
m merge
mt mergetool

l log --show-signature
sl shortlog
rl reflog"

# I've spent almost 20 minutes on this, and no, I really couldn't think of a
# better way to express this loop.
for _ in seq $(($# / 2)); do
	short=$1
	long=$2
	shift 2
	echo "alias $short='$long'" | tr -d '\\'
	echo "$subcommands" | sed s/" "/"='$long "/ | while read rhs; do
		[ -n "$rhs" ] && printf "alias %s%s'\n" "$short" "$rhs"
	done
	echo ""
done