From eb19fc16c9b59e79da9158f721c7584e831aaff3 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 24 Jun 2019 22:18:22 +0800 Subject: Add acme/a script to better start Acme editor Credit: https://github.com/evbogdanov/acme --- acme/a | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 acme/a (limited to 'acme/a') diff --git a/acme/a b/acme/a new file mode 100755 index 0000000..4d51ab7 --- /dev/null +++ b/acme/a @@ -0,0 +1,71 @@ +#!/bin/sh +# +# Copyright (c) 2019 Aaron LI +# MIT License +# + +# Default font and size +fontname=NotoSansMono-Regular +fontsize=11 + +usage() { + echo "usage: ${0##*/} [-f [fontname][:fontsize]] [acme_args ...]" >&2 + echo "defaults: fontname: '${fontname}', fontsize: ${fontsize}" >&2 + exit 1 +} + +is_running() { + pgrep -x -u "${USER}" "$1" >/dev/null 2>&1 +} + +get_font() { + local name size + case $1 in + *:*) + name="${1%:*}" + size="${1#*:}" + ;; + *) + name="$1" + ;; + esac + name="${name:-$2}" + size="${size:-$3}" + echo "/mnt/font/${name}/${size}a/font" +} + +[ -n "${PLAN9}" ] || { + echo "ERROR: Environment variable 'PLAN9' not set!" >&2 + exit 2 +} + +while getopts :f:h opt; do + case ${opt} in + f) + font="${OPTARG}" + ;; + h) + usage + ;; + \?) + echo "Invalid option -${OPTARG}" >&2 + usage + ;; + :) + echo "Option -${OPTARG} requires an argument" >&2 + usage + ;; + esac +done +shift $((${OPTIND} - 1)) + +FONT=$(get_font "${font}" ${fontname} ${fontsize}) + +is_running fontsrv || fontsrv & +is_running plumber || plumber + +export PAGER=nobs +export TERM=dumb +export tabstop=8 + +exec ${PLAN9}/bin/acme -a -f "${FONT}" "$@" -- cgit v1.2.2