From 7e087d8eda67010bae97d8b268b71a263c02ac87 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 16 Jan 2024 17:11:58 +0100 Subject: [PATCH] __fish_make_cache_dir: Create fish subdir and optionally deeper This will move all current cache uses to e.g. ~/.cache/fish/ That's better anyway because it makes it easier to remove. Also it allows supplying a subdir so you can do `__fish_make_cache_dir completions` to get ~/.cache/fish/completions. --- share/functions/__fish_make_cache_dir.fish | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_make_cache_dir.fish b/share/functions/__fish_make_cache_dir.fish index 0efd1e7d9..e068027ba 100644 --- a/share/functions/__fish_make_cache_dir.fish +++ b/share/functions/__fish_make_cache_dir.fish @@ -3,6 +3,10 @@ function __fish_make_cache_dir --description "Create and return XDG_CACHE_HOME" if test -z "$xdg_cache_home"; or string match -qv '/*' -- $xdg_cache_home; or set -q xdg_cache_home[2] set xdg_cache_home $HOME/.cache end - mkdir -m 700 -p $xdg_cache_home - and echo $xdg_cache_home + + # If we get an argument, we try to create that as a subdirectory. + # So if you call `__fish_make_cache_dir completions`, + # this creates e.g. ~/.cache/fish/completions + mkdir -m 700 -p $xdg_cache_home/fish/"$argv[1]" + and echo $xdg_cache_home/fish/"$argv[1]" end