From 09ddac1d7ac660265ade94ad66fad7b8150b03d4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Jun 2022 01:59:56 +0200 Subject: [PATCH] feat(cli): resolve EMACSDIR to doomscript's parent directory If no EMACSDIR is given, assume ../ is the Emacs config we want to operate out of, taking after bin/doom. And use bash. This script was designed for the convenience of other scripters on unix systems, so it can afford a small hit to portability. --- bin/doomscript | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/bin/doomscript b/bin/doomscript index c6626de3c..d6db3c349 100755 --- a/bin/doomscript +++ b/bin/doomscript @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # This is a shebang interpreter for launching emacs lisp scripts with Doom's CLI # framework preloaded and all the metadata it needs initialized. Use it like so: # @@ -22,7 +22,7 @@ case "$EMACS" in *) EMACS="${EMACS:-emacs}" ;; esac -TMPDIR=${TMPDIR:-`$EMACS -Q --batch --eval '(princ (temporary-file-directory))' 2>/dev/null`} +TMPDIR="${TMPDIR:-$($EMACS -Q --batch --eval '(princ (temporary-file-directory))' 2>/dev/null)}" if [ -z "$TMPDIR" ]; then >&2 echo "Error: failed to run Emacs with command '$EMACS'" >&2 echo @@ -30,15 +30,7 @@ if [ -z "$TMPDIR" ]; then exit 1 fi -if [ -z "$EMACSDIR" ]; then - EMACSDIR="${XDG_CONFIG_HOME:-$HOME/.config}/emacs" - [ -d "$EMACSDIR" ] || EMACSDIR="$HOME/.emacs.d" - if [ ! -d "$EMACSDIR" ]; then - >&2 echo "Failed to find \$EMACSDIR in ~/.config/emacs or ~/.emacs.d" - exit 1 - fi -fi - +export EMACSDIR="${EMACSDIR:-$(cd $(dirname "$BASH_SOURCE")/.. && pwd)}" export __DOOMPID="${__DOOMPID:-$$}" export __DOOMSTEP="$((__DOOMSTEP+1))" export __DOOMGEOM="${__DOOMGEOM:-`tput cols lines 2>/dev/null`}"