From 645a6858b6cbe3966c5c1b016d0d1cef26cf224d Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg <zanderpkg@pm.me> Date: Sat, 22 Feb 2025 03:49:54 -0800 Subject: [PATCH] Fix tramp creating random files --- init.zsh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/init.zsh b/init.zsh index 8b907d9..f825b27 100644 --- a/init.zsh +++ b/init.zsh @@ -55,8 +55,23 @@ unsetopt beep notify # Some general, random configuration # History stuff +if [[ -v INSIDE_EMACS ]]; then + () { + emulate -L zsh + set -o rematchpcre + if [[ "${HISTFILE}" =~ '^~([^/]*)($|/.*)' ]]; then + local user="${match[1]}" + local rest="${match[2]}" + if [[ -z "${user}" ]]; then + HISTFILE="${HOME}${rest}" + else + HISTFILE="${userdirs[${user}]}" + fi + fi + } +fi +[[ "${HISTFILE}" == '~'* ]] && HISTFILE="${HISTFILE}" [ -v HISTFILE ] || HISTFILE="${HOME}/.cache/zsh/history" -[ ! -d "${HISTFILE:h}" ] && mkdir -p "${HISTFILE:h}" HISTSIZE=1000 SAVEHIST=10000