From 7344512c3ad048f59088200f3c488078a567face Mon Sep 17 00:00:00 2001 From: Tim McCarthy Date: Sun, 12 Oct 2025 13:48:06 -0700 Subject: [PATCH] Fix yas bash snippets --- emacs/reset.sh | 11 +++++++++-- emacs/snippets/sh-mode/bang | 4 ++-- emacs/snippets/sh-mode/sdir | 6 +++--- emacs/snippets/sh-ts-mode/.yas-parents | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 emacs/snippets/sh-ts-mode/.yas-parents diff --git a/emacs/reset.sh b/emacs/reset.sh index 2623264..34f0fae 100755 --- a/emacs/reset.sh +++ b/emacs/reset.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash -SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +# See https://stackoverflow.com/a/246128/3561275 +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" -pushd $SCRIPT_DIR &>/dev/null && rm -rf eln-cache elpa elpaca elpaca.lock && popd &> /dev/null +pushd $DIR &>/dev/null && rm -rf eln-cache elpa elpaca elpaca.lock && popd &> /dev/null diff --git a/emacs/snippets/sh-mode/bang b/emacs/snippets/sh-mode/bang index 5e11f0e..40dcbb8 100644 --- a/emacs/snippets/sh-mode/bang +++ b/emacs/snippets/sh-mode/bang @@ -1,6 +1,6 @@ # -*- mode: snippet -*- -# name: bang +# name: shebang # key: ! # -- #!/usr/bin/env bash -$0 \ No newline at end of file +$0 diff --git a/emacs/snippets/sh-mode/sdir b/emacs/snippets/sh-mode/sdir index 49cf35e..52f5b3a 100644 --- a/emacs/snippets/sh-mode/sdir +++ b/emacs/snippets/sh-mode/sdir @@ -1,6 +1,6 @@ # -*- mode: snippet -*- -# name: the currently executing/sourced script's directory -# key: script-dir +# name: current script's directory +# key: sdir # -- # See https://stackoverflow.com/a/246128/3561275 SOURCE="\${BASH_SOURCE[0]}" @@ -11,4 +11,4 @@ while [ -h "\$SOURCE" ]; do # resolve \$SOURCE until the file is no longer a sym done DIR="\$( cd -P "\$( dirname "\$SOURCE" )" >/dev/null 2>&1 && pwd )" -$0 \ No newline at end of file +$0 diff --git a/emacs/snippets/sh-ts-mode/.yas-parents b/emacs/snippets/sh-ts-mode/.yas-parents new file mode 100644 index 0000000..04d079b --- /dev/null +++ b/emacs/snippets/sh-ts-mode/.yas-parents @@ -0,0 +1 @@ +sh-mode