From f202c025c0032fdf457ea216f542eb01a85be217 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Tue, 20 Jun 2023 17:15:28 -0400 Subject: [PATCH] Update `tag` aliases to utilize mktemp for the temporary file --- chezmoi/dot_zshrc.d/executable_tag.zsh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/chezmoi/dot_zshrc.d/executable_tag.zsh b/chezmoi/dot_zshrc.d/executable_tag.zsh index 4254571..0643096 100644 --- a/chezmoi/dot_zshrc.d/executable_tag.zsh +++ b/chezmoi/dot_zshrc.d/executable_tag.zsh @@ -1,11 +1,25 @@ if command -v tag &> /dev/null; then if command -v ag &> /dev/null; then - tag() { export TAG_SEARCH_PROG=ag; command tag "$@"; source ${TAG_ALIAS_FILE:-/tmp/tag_aliases} 2>/dev/null } + tag() { + export TAG_SEARCH_PROG=ag + export TAG_ALIAS_FILE="$(mktemp)" + command tag "$@" + source ${TAG_ALIAS_FILE:-/tmp/tag_aliases} &> /dev/null + rm -f "$TAG_ALIAS_FILE" &> /dev/null + } + alias ag=tag fi if command -v rg &> /dev/null; then - trg() { export TAG_SEARCH_PROG=rg; command tag "$@"; source ${TAG_ALIAS_FILE:-/tmp/tag_aliases} 2>/dev/null } + trg() { + export TAG_SEARCH_PROG=rg + export TAG_ALIAS_FILE="$(mktemp)" + command tag "$@" + source ${TAG_ALIAS_FILE:-/tmp/tag_aliases} &> /dev/null + rm -f "$TAG_ALIAS_FILE" &> /dev/null + } + alias rg=trg fi fi