mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
Extract creating $XDG_CACHE_HOME into its own function
This commit is contained in:
parent
24012b1941
commit
97838657b9
4 changed files with 16 additions and 16 deletions
9
share/functions/__fish_make_cache_dir.fish
Normal file
9
share/functions/__fish_make_cache_dir.fish
Normal file
|
@ -0,0 +1,9 @@
|
|||
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
|
||||
mkdir -m 700 -p $xdg_cache_home
|
||||
and echo $xdg_cache_home
|
||||
end
|
||||
|
|
@ -32,11 +32,8 @@ function __fish_print_packages
|
|||
and return
|
||||
|
||||
# Set up cache directory
|
||||
set -l xdg_cache_home $XDG_CACHE_HOME
|
||||
if test -z "$xdg_cache_home"
|
||||
set xdg_cache_home $HOME/.cache
|
||||
end
|
||||
mkdir -m 700 -p $xdg_cache_home
|
||||
set -l xdg_cache_home (__fish_make_cache_dir)
|
||||
or return
|
||||
|
||||
# yum is slow, just like rpm, so go to the background
|
||||
if type -q -f /usr/share/yum-cli/completion-helper.py
|
||||
|
|
|
@ -5,12 +5,9 @@ function __fish_print_pacman_packages
|
|||
argparse i/installed -- $argv
|
||||
or return 1
|
||||
|
||||
# Set up cache directory
|
||||
set -l xdg_cache_home $XDG_CACHE_HOME
|
||||
if test -z "$xdg_cache_home"
|
||||
set xdg_cache_home $HOME/.cache
|
||||
end
|
||||
mkdir -m 700 -p $xdg_cache_home
|
||||
set -l xdg_cache_home (__fish_make_cache_dir)
|
||||
or return
|
||||
|
||||
if not set -q only_installed
|
||||
set -l cache_file $xdg_cache_home/.pac-cache.$USER
|
||||
if test -f $cache_file
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
function __fish_print_zypper_packages
|
||||
type -q -f zypper || return 1
|
||||
|
||||
set -l xdg_cache_home $XDG_CACHE_HOME
|
||||
if test -z "$xdg_cache_home"
|
||||
set xdg_cache_home $HOME/.cache
|
||||
end
|
||||
mkdir -m 700 -p $xdg_cache_home
|
||||
set -l xdg_cache_home (__fish_make_cache_dir)
|
||||
or return
|
||||
|
||||
# Use libzypp cache file if available
|
||||
if test -f /var/cache/zypp/solv/@System/solv.idx
|
||||
|
|
Loading…
Reference in a new issue