From c274475635d410c0e9f812e71d20183cb923cd6b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 18 Feb 2024 13:22:42 +0100 Subject: misc updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- cat-with-head | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 cat-with-head (limited to 'cat-with-head') diff --git a/cat-with-head b/cat-with-head new file mode 100755 index 0000000..81e73bd --- /dev/null +++ b/cat-with-head @@ -0,0 +1,19 @@ +#!/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 -- cgit v1.2.3-70-g09d2