mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
Simplify freedesktop icon completions
Use `path` more and skip the `sort` - this is for completions and they're sorted internally.
This commit is contained in:
parent
f07e6c6667
commit
a23cfd0aa8
|
@ -1,28 +1,15 @@
|
||||||
function __fish_complete_freedesktop_icons -d 'List installed icon names according to `https://specifications.freedesktop.org/icon-theme-spec/0.13/`'
|
function __fish_complete_freedesktop_icons -d 'List installed icon names according to `https://specifications.freedesktop.org/icon-theme-spec/0.13/`'
|
||||||
# The latest `icon-theme-spec` as of 2024-08-10 is 0.13
|
# The latest `icon-theme-spec` as of 2024-08-10 is 0.13
|
||||||
# https://specifications.freedesktop.org/icon-theme-spec/latest/
|
# https://specifications.freedesktop.org/icon-theme-spec/latest/
|
||||||
# https://specifications.freedesktop.org/icon-theme-spec/0.13/
|
|
||||||
|
|
||||||
# https://specifications.freedesktop.org/icon-theme-spec/0.13/#directory_layout
|
# https://specifications.freedesktop.org/icon-theme-spec/0.13/#directory_layout
|
||||||
# 1. $HOME/.icons
|
# 1. $HOME/.icons
|
||||||
# 2. $XDG_DATA_DIRS/icons
|
# 2. $XDG_DATA_DIRS/icons
|
||||||
# 3. /usr/share/pixmaps
|
# 3. /usr/share/pixmaps
|
||||||
set -l dirs
|
set -l dirs (path filter -rd -- ~/.icons $XDG_DATA_DIRS/icons /usr/share/pixmaps)
|
||||||
test -d $HOME/.icons; and set -a dirs $HOME/.icons
|
|
||||||
if set -q XDG_DATA_DIRS
|
|
||||||
# Can be a list of directories so we append each
|
|
||||||
for d in $XDG_DATA_DIRS
|
|
||||||
test -d $d/icons; and set -a dirs $d/icons
|
|
||||||
end
|
|
||||||
end
|
|
||||||
test -d /usr/share/pixmaps; and set -a dirs /usr/share/pixmaps
|
|
||||||
|
|
||||||
for d in $dirs
|
# https://specifications.freedesktop.org/icon-theme-spec/0.13/#definitions
|
||||||
# https://specifications.freedesktop.org/icon-theme-spec/0.13/#definitions
|
# .png, .svg and .xpm are valid icon file formats
|
||||||
# .png, .svg and .xpm are valid icon file formats
|
path filter -rf -- $dirs/**/*.{png,svg,xpm} \
|
||||||
printf '%s\n' $d/**/*.{png,svg,xpm}
|
|
||||||
end \
|
|
||||||
| path basename \
|
| path basename \
|
||||||
| path change-extension '' \
|
| path change-extension ''
|
||||||
| command sort --unique
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user