~wrm/dotfiles

ref: f0dc804d36d6538ff9bac8af4e32a3210a2826b0 dotfiles/.config/shell/git-aliases.sh -rwxr-xr-x 654 bytes
f0dc804d — +wrm shell: Add git aliases generating script 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
36
#!/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
	shift
	long=$1
	shift
	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