summaryrefslogtreecommitdiff
path: root/help
blob: 1b74237a53bba74f3def9c9ce6f80346fb0a43d6 (about) (plain) (blame)
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
#!/bin/sh
# Send help. I'm trapped in the machine.

echo -e "\e]0;$USER@$HOSTNAME\e\\"

if [ $# -eq 0 ]; then
	cd "$(dirname "$0")"
	echo "Commands available:"
	find -L . -maxdepth 1 -type f \! -name '.*' -execdir perl -e '$w=80;$buf=""; for (@ARGV) { s@^\./@@; if (length("$buf $_") > $w) { print("$buf\n"); $buf = ""; } $buf .= " $_"; } print("$buf\n");' {} +
	echo
	status=""
	git diff --no-ext-diff --quiet || status="${status}*"
	git diff --no-ext-diff --cached --quiet || status="${status}+"
	git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null && status="${status}%"
	echo -e "This is \e]8;;https://cgit.space/~cgitspace/git-shell-commands/.git/tree/?id=$(git rev-parse HEAD)\e\\https://cgit.space/~cgitspace/git-shell-commands.git\e]8;;\e\\@$(git describe --long --always)$status"
else
	if [[ $1 == *.* ]]; then
		echo "No ." >&2
		exit 1
	fi
	if [[ $1 == */* ]]; then
		echo "No ." >&2
		exit 1
	fi

	sed '/^#!/d;/^\([^#]\|$\)/Q;s/^# \?//' "$(dirname "$0")/$1"
fi