From 026d9f86c67790d96ded1de8faeaba213a9f5631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 24 May 2021 13:31:06 +0200 Subject: First commit --- Makefile | 4 ++++ vp | 2 ++ vp.1 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ vpeval | 4 ++++ vprc | 2 ++ 5 files changed, 64 insertions(+) create mode 100644 Makefile create mode 100755 vp create mode 100644 vp.1 create mode 100755 vpeval create mode 100644 vprc diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7f4e544 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +install: + install vp vpeval /usr/local/bin/ + cp vp.1 /usr/local/man/man1/vp.1 + cp vprc /usr/local/etc/vprc diff --git a/vp b/vp new file mode 100755 index 0000000..366a1b6 --- /dev/null +++ b/vp @@ -0,0 +1,2 @@ +#!/bin/sh +exec vi +':so /usr/local/etc/vprc' "$@" `mktemp` diff --git a/vp.1 b/vp.1 new file mode 100644 index 0000000..54f3a62 --- /dev/null +++ b/vp.1 @@ -0,0 +1,52 @@ +.Dd $Mdocdate$ +.Dt vp 1 +.Os +. +.Sh NAME +.Nm vp +.Nd run commands interactively +. +.Sh SYNOPSIS +.Nm +.Op Ar arg ... +. +.Sh DESCIPTION +.Pp +.Nm +opens +.Xr vi 1 +with two custom key mappings, defined in +.Pa /usr/local/etc/vprc : +.Bl -tag +.It Sy g +Execute the buffer as a shell command +and append the output to the buffer +with each line beginning with +.Sq #\ . +Lines beginning with +.Sq # +are ignored by +.Sy g . +.It Sy q +Remove any lines not beginning with +.Sq # +and remove the +.Sq #\ +prefix from all remaining lines. +.El +.Pp +These mappings are useful for interactively testing shell commands. +Any arguments given to +.Nm +are passed on to +.Xr vi 1 . +. +.Sh AUTHORS +.Pp +.Nm +is written by John Ankarström +.Aq Mt john (at) ankarstrom.se . +It is inspired by Mateusz Czapliński's +.Em up +.Dq ( Ultimate Plumber ) +tool. diff --git a/vpeval b/vpeval new file mode 100755 index 0000000..bd0db27 --- /dev/null +++ b/vpeval @@ -0,0 +1,4 @@ +#!/bin/sh +c=`cat | sed '/^#/d'` +echo "$c" +echo "$(eval "$c" 2>&1)" | sed 's/^/# /' diff --git a/vprc b/vprc new file mode 100644 index 0000000..6616e50 --- /dev/null +++ b/vprc @@ -0,0 +1,2 @@ +map g :1,$!vpeval /^# k$ +map q :1,/^#/-1d :%s/^# //g :1 -- cgit v1.2.3