lsd-rs / lsd

The next gen ls command
Apache License 2.0
13.45k stars 436 forks source link

[Bug]: `icons.yaml` does not seem to override icons #1082

Open hawkw opened 2 months ago

hawkw commented 2 months ago

Version

version

eliza@theseus ~ $ lsd --version
lsd 1.1.2

What OS are you seeing the problem on?

Linux

installation

From Nixpkgs

term

eliza@theseus ~ $ echo $TERM
alacritty

ls-colors

eliza@theseus ~ $ echo $LS_COLORS
rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.7z=01;31:*.ace=01;31:*.alz=01;31:*.apk=01;31:*.arc=01;31:*.arj=01;31:*.bz=01;31:*.bz2=01;31:*.cab=01;31:*.cpio=01;31:*.crate=01;31:*.deb=01;31:*.drpm=01;31:*.dwm=01;31:*.dz=01;31:*.ear=01;31:*.egg=01;31:*.esd=01;31:*.gz=01;31:*.jar=01;31:*.lha=01;31:*.lrz=01;31:*.lz=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.lzo=01;31:*.pyz=01;31:*.rar=01;31:*.rpm=01;31:*.rz=01;31:*.sar=01;31:*.swm=01;31:*.t7z=01;31:*.tar=01;31:*.taz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tgz=01;31:*.tlz=01;31:*.txz=01;31:*.tz=01;31:*.tzo=01;31:*.tzst=01;31:*.udeb=01;31:*.war=01;31:*.whl=01;31:*.wim=01;31:*.xz=01;31:*.z=01;31:*.zip=01;31:*.zoo=01;31:*.zst=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:

What happened?

I have an icons.yaml file in $HOME/config/lsd/icons.yaml. The icons.theme key in $HOME/.config/lsd/config.yaml is set to "unicode", and icons.when is set to "auto". However, my specified file type icons in icons.yaml do not seem to override the defaults.

For example:

eliza@theseus ~ $ lsd ~/.config/lsd
🔖 config.yaml  🔖 icons.yaml

eliza@theseus ~ $ cat ~/.config/lsd/config.yaml
color:
  when: auto
hyperlink: auto
icons:
  separator: ' '
  theme: unicode
  when: auto

eliza@theseus ~ $ cat ~/.config/lsd/icons.yaml
filetype:
  device_block: 🖴
  device_char: 🖵
  dir: 🗀
  executable: 🗔
  file: 🗎
  pipe: ⭍
  socket: 🖧

eliza@theseus ~ $ ls
📂 Code  📂 Desktop  📂 Documents  📂 Downloads  📄 hubris.core.ringbuf-counts  📂 keybase  📂 Music  📂 Pictures  📂 Public  📄 se.jpeg  📂 Templates  📂 Videos  📄 vudials.log

eliza@theseus ~ $ lsd
📂 Code       📂 Downloads                   📂 Music     📄 se.jpeg    📄 vudials.log
📂 Desktop    📄 hubris.core.ringbuf-counts  📂 Pictures  📂 Templates
📂 Documents  📂 keybase                     📂 Public    📂 Videos

eliza@theseus ~ $ lsd /dev
🖨 autofs           🖨 hidraw2      🖨 kvm           🔖 rtc      🖨 tty26  🖨 tty54        🖨 vcs6
📂 block           🖨 hpet         🔖 log          🖨 rtc0      🖨 tty27  🖨 tty55        🖨 vcs7
🖨 btrfs-control    📂 hugepages   🖨 loop-control  📂 shm      🖨 tty28  🖨 tty56        🖨 vcsa
📂 bus             🖨 hwrng        💽 loop0        🖨 snapshot  🖨 tty29  🖨 tty57        🖨 vcsa1
📂 char            🖨 i2c-0        💽 loop1        📂 snd      🖨 tty3   🖨 tty58        🖨 vcsa2
🖨 console          🖨 i2c-1        💽 loop2        🔖 stderr   🖨 tty30  🖨 tty59        🖨 vcsa3
🔖 core            🖨 i2c-10       💽 loop3        🔖 stdin    🖨 tty31  🖨 tty6         🖨 vcsa4
📂 cpu             🖨 i2c-11       💽 loop4        🔖 stdout   🖨 tty32  🖨 tty60        🖨 vcsa5
🖨 cpu_dma_latency  🖨 i2c-12       💽 loop5        🖨 tee0      🖨 tty33  🖨 tty61        🖨 vcsa6
🖨 cuse             🖨 i2c-13       💽 loop6        🖨 tpm0      🖨 tty34  🖨 tty62        🖨 vcsa7
🖨 dbc              🖨 i2c-14       💽 loop7        🖨 tpmrm0    🖨 tty35  🖨 tty63        🖨 vcsu
📂 disk            🖨 i2c-15       📂 mapper       🖨 tty       🖨 tty36  🖨 tty7         🖨 vcsu1
💽 dm-0            🖨 i2c-16       🖨 media0        🖨 tty0      🖨 tty37  🖨 tty8         🖨 vcsu2
💽 dm-1            🖨 i2c-17       🖨 mem           🖨 tty1      🖨 tty38  🖨 tty9         🖨 vcsu3
📂 dri             🖨 i2c-18       📂 mqueue       🖨 tty10     🖨 tty39  🖨 ttyS0        🖨 vcsu4
🖨 drm_dp_aux0      🖨 i2c-19       📂 net          🖨 tty11     🖨 tty4   🖨 ttyS1        🖨 vcsu5
🖨 drm_dp_aux1      🖨 i2c-2        🖨 ng0n1         🖨 tty12     🖨 tty40  🖨 ttyS2        🖨 vcsu6
🖨 drm_dp_aux2      🖨 i2c-20       🖨 null          🖨 tty13     🖨 tty41  🖨 ttyS3        🖨 vcsu7
🖨 drm_dp_aux3      🖨 i2c-21       🖨 nvme0         🖨 tty14     🖨 tty42  🖨 udmabuf      📂 vfio
🖨 drm_dp_aux4      🖨 i2c-22       💽 nvme0n1      🖨 tty15     🖨 tty43  🖨 uhid         🖨 vga_arbiter
🖨 drm_dp_aux5      🖨 i2c-3        💽 nvme0n1p1    🖨 tty16     🖨 tty44  🖨 uinput       🖨 vhci
🖨 drm_dp_aux6      🖨 i2c-4        💽 nvme0n1p2    🖨 tty17     🖨 tty45  🖨 urandom      🖨 vhost-net
🖨 drm_dp_aux7      🖨 i2c-5        💽 nvme0n1p3    🖨 tty18     🖨 tty46  🖨 userfaultfd  🖨 vhost-vsock
🖨 drm_dp_aux8      🖨 i2c-6        🖨 nvram         🖨 tty19     🖨 tty47  🖨 userio       🖨 video0
🖨 fb0              🖨 i2c-7        🖨 port          🖨 tty2      🖨 tty48  📂 v4l         🖨 video1
🗂 fd               🖨 i2c-8        🖨 ppp           🖨 tty20     🖨 tty49  🖨 vcs          🖨 watchdog
🖨 full             🖨 i2c-9        🖨 ptmx          🖨 tty21     🖨 tty5   🖨 vcs1         🖨 watchdog0
🖨 fuse             🖨 iio:device0  📂 pts          🖨 tty22     🖨 tty50  🖨 vcs2         🖨 zero
🖨 gpiochip0        📂 input       🖨 random        🖨 tty23     🖨 tty51  🖨 vcs3
🖨 hidraw0          🖨 kfd          🖨 rfkill        🖨 tty24     🖨 tty52  🖨 vcs4
🖨 hidraw1          🖨 kmsg         🔖 root         🖨 tty25     🖨 tty53  🖨 vcs5

eliza@theseus ~ $

Note that the overridden directory, block device, char device, and file icons in icons.yaml are not used.

What expected?

I would have expected the overridden icons to be used, as described in the README here.

What else?

It seems like the documentation on setting a custom icon theme in the README may no longer describe lsd's actual behavior? Looking at lsd/src/theme.rs, it looks like the Theme struct now attempts to parse an icon theme, color theme, and Git symbols from the same file: https://github.com/lsd-rs/lsd/blob/9b310da60085eace5b03c0eba6a3cfa6cbf378de/src/theme.rs#L18-L26

https://github.com/lsd-rs/lsd/blob/9b310da60085eace5b03c0eba6a3cfa6cbf378de/src/theme.rs#L39-L83

I'd be happy to open a PR to either update the documentation or fix the implementation so that it does what the documentation says! However, before doing that, it would be great to hear from the maintainers regarding what the intended behavior here is. Is the icon theme still supposed to be parsed from $XDG_CONFIG_HOME/lsd/icons.yaml as described in the README, or is the apparent behavior of parsing both the icons and color theme from the same YAML file correct? If the current behavior is intended, how is the new theme file supposed to be used --- where should it be located, and how do I point lsd at it?

hxlnt commented 1 month ago

@hawkw FYI, this appears to be fixed as of version 1.1.5. Here are some custom overrides in my icons.yaml file:

Screenshot from 2024-10-01 00-12-07

ttoino commented 2 weeks ago

The custom icons are only applied when the icon theme is fancy, as evidenced by these lines:

https://github.com/lsd-rs/lsd/blob/82124fd0b946855254721117d7ba004c377d0f44/src/icon.rs#L16-L26

This should ideally be reflected in the documentation, I spent quite a while trying to figure out why my icons were not working.

nilp0inter commented 2 weeks ago

@hxlnt , I am not able to reproduce your setup with the same version. Could you please share your icons.yaml file?

hxlnt commented 2 weeks ago

@nilp0inter Sure, though the characters won't render correctly here, as they require a Nerdfont. I've also included my config.yaml.

config.yaml:

classic: false
blocks:
  - name
  - size
  - date
color:
  when: auto
  theme: custom
date: relative
dereference: false
icons:
  when: always
  theme: fancy
  separator: " "
indicators: false
layout: tree
recursion:
  enabled: false
  depth: 1
size: short
sorting:
  column: name
  reverse: false
  dir-grouping: first
no-symlink: false
total-size: false
hyperlink: always
symlink-arrow: ⇒
header: true

icons.yaml

name:
  .bashrc: 
  .eslintrc.js: 
  .eslintrc.json: 
  .eslintrc.yml: 
  .git: 
  .gitignore: 
  .gitlab-ci.yml: 
  .todo: 
  .trash: 
  commit_editmsg: 
  config: 
  desktop: 
  description: 
  documents: 
  downloads: 
  fetch_head: 
  go.mod: 
  go.sum: 
  head: 
  heroku.yml: 
  index: 
  lib: 
  license: 
  makefile: 
  music: 
  node_modules: 
  orig_head: 
  package.json: 
  pictures: 
  public: 
  pyproject.toml: 
  scripts: 
  src: 
  tests: 
  videos: 
extension:
  1: 
  2: 
  3: 
  4: 
  asm: 
  avi: 
  bak: 
  bat: 
  bin: 
  bmp: 
  c: 
  cpp: 
  cert: 
  cfg: 
  cson: 
  css: 
  csv: 
  db: 
  deb: 
  doc: 
  docx: 
  ejs: 
  exe: 
  go: 
  gif: 
  git: 
  h: 
  hpp: 
  hex: 
  htm: 
  html: 
  img: 
  ini: 
  ino: 
  jpeg: 
  jpg: 
  js: 
  json: 
  jsx: 
  key: 
  list: 
  lock: 
  log: 
  lua: 
  md: 
  m4v: 
  mpeg: 
  mpg: 
  nes: 
  nfo: 
  old: 
  otf: 
  png: 
  ppt: 
  pptx: 
  py: 
  rar: 
  rom: 
  rs: 
  rss: 
  save: 
  sh: 
  tar: 
  toml: 
  ts: 
  tsx: 
  ttf: 
  txt: 
  vue: 
  xls: 
  xlsx: 
  xml: 
  yaml: 
  yml: 
  zip: 
filetype:
  dir: 
  file: 
nilp0inter commented 1 week ago

@hxlnt Thanks! I was able to identify the issue. It turned out that I was trying to override the Downloads folder, but it wasn't having the desired effect. Upon further investigation, I discovered that the keys should be in lowercase. To successfully override the icon in the Downloads directory, I had to include a downloads entry.