From 765b03643d6668c3ad10aab806daa232ef30e72f Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Sun, 29 Aug 2021 11:46:33 +0800 Subject: [PATCH] Respect `$TMPDIR` if it exists --- neofetch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index 8ee14ba1697..642d8812392 100755 --- a/neofetch +++ b/neofetch @@ -4807,10 +4807,11 @@ cache() { } get_cache_dir() { - case $os in - "Mac OS X"|"macOS") cache_dir="/Library/Caches" ;; - *) cache_dir="/tmp" ;; - esac + if [[ "$TMPDIR" ]]; then + cache_dir="$TMPDIR" + else + cache_dir="/tmp" + fi } kde_config_dir() { @@ -5363,8 +5364,7 @@ get_args() { "--gap") gap="$2" ;; "--clean") [[ -d "$thumbnail_dir" ]] && rm -rf "$thumbnail_dir" - rm -rf "/Library/Caches/neofetch/" - rm -rf "/tmp/neofetch/" + rm -rf "$cache_dir/neofetch/" exit ;; @@ -11477,6 +11477,7 @@ EOF main() { cache_uname get_os + get_cache_dir # Load default config. eval "$config" @@ -11499,7 +11500,6 @@ main() { } image_backend - get_cache_dir old_functions print_info dynamic_prompt