2020-09-23 01:17:15 +08:00
|
|
|
function __fish_make_cache_dir --description "Create and return XDG_CACHE_HOME"
|
|
|
|
set -l xdg_cache_home $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
|
2024-01-17 00:11:58 +08:00
|
|
|
|
|
|
|
# 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
|
2024-05-31 06:03:03 +08:00
|
|
|
if not path is -d $xdg_cache_home/fish/"$argv[1]"
|
|
|
|
mkdir -m 700 -p $xdg_cache_home/fish/"$argv[1]"
|
|
|
|
end; and echo $xdg_cache_home/fish/"$argv[1]"
|
2020-09-23 01:17:15 +08:00
|
|
|
end
|