dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 42afdc740078d685323495749cfdd5ffe345b089
parent 1c749875a04fa335c3f5869fce276132b4213ce5
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Tue,  7 Jan 2020 05:17:35 -0500

acme: Additional (custom) commands

Diffstat:
Alib/acme/Sudo | 27+++++++++++++++++++++++++++
Alib/acme/a+ | 21+++++++++++++++++++++
Alib/acme/a- | 21+++++++++++++++++++++
3 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/lib/acme/Sudo b/lib/acme/Sudo @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ -z "$SUDO_ASKPASS" ] +then + echo "SUDO_ASKPASS not defined" >&2 + exit +fi + +if [ $# -eq 0 ] +then + fname=$(9p read acme/$winid/tag | awk '{ print $1 }') + 9p read acme/$winid/body | sudo tee $fname >/dev/null 2>&1 + echo clean | 9p write acme/$winid/ctl +else + if echo $1 | grep -E '^/' > /dev/null 2>&1 + then + fname=$1 + else + fname=$(pwd)/$1 + fi + echo name $fname | 9p write acme/new/ctl + winid=$(9p read acme/index | grep $fname | awk '{ print $1 }') + echo -n 'Sudo ' | 9p write acme/$winid/tag + sudo cat $fname | 9p write acme/$winid/body + echo clean | 9p write acme/$winid/ctl +fi+ \ No newline at end of file diff --git a/lib/acme/a+ b/lib/acme/a+ @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ $# -gt 1 ] +then + echo "Too many arguments" >&2 + exit 1 +elif [ $# -eq 1 ] +then + i=0 + token='' + while [ $i -lt $1 ] + do + token="$token " + i=$(($i + 1)) + done +else + token=' ' +fi + +sed "s/^/$token/"+ \ No newline at end of file diff --git a/lib/acme/a- b/lib/acme/a- @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ $# -gt 1 ] +then + echo "Too many arguements (expecting 0 or 1)" >&2 + exit 1 +elif [ $# -eq 1 ] +then + i=0 + token='' + while [ $i -lt $1 ] + do + token="$token " + i=$(($i + 1)) + done +else + token=' ' +fi + +sed "s/$token//"+ \ No newline at end of file