aboutsummaryrefslogblamecommitdiffstats
path: root/cat-with-head
blob: 81e73bd2d7fc7bd021b78029ed4ddbede69c6a5c (plain) (tree)


















                                                                               
#!/bin/sh
set -e
home="$(printf '%s\n' "$HOME" | sed 's:/\+:/:g' | sed '$s:/$::g')"
if test -z "$(printf '%s\n' "$home" | tr -d '[A-Za-z0-9_/-]')"; then
	pretty_filename () {
		printf '%s' "$1" | sed '1s:^'"${home}"'/:~/:' | sed 's:/\+:/:g'
	}
else
	pretty_filename () {
		printf '%s' "$1" | sed 's:/\+:/:g'
	}
fi
if test "$1" = "--"; then
	shift 1
fi
for file; do
	printf '\n\n\n### %s\n\n' "$(pretty_filename "$(realpath -- "$file")")"
	cat -- "$file"
done