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.
This commit is contained in:
parent
74f3c1d11c
commit
09ddac1d7a
1 changed files with 3 additions and 11 deletions
|
@ -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`}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue