lsd icon indicating copy to clipboard operation
lsd copied to clipboard

Should use the last `--block` options if multiple occurred

Open alephalpha0 opened this issue 4 years ago • 2 comments

  • os: Android 10 aarch64 (via Termux 0.108)
  • lsd --version: lsd 0.19.0
  • echo $TERM: xterm-256color
  • 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=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lha=01;31:.lz4=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.tzo=01;31:.t7z=01;31:.zip=01;31:.z=01;31:.dz=01;31:.gz=01;31:.lrz=01;31:.lz=01;31:.lzo=01;31:.xz=01;31:.zst=01;31:.tzst=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.alz=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.cab=01;31:.wim=01;31:.swm=01;31:.dwm=01;31:.esd=01;31:.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:

Expected behavior

This is what occurs when I don't have alias lsd="lsd -lAF --blocks=permission,size,date,name --date=relative --total-size --group-dirs first" and alias ls="lsd -lAF --blocks=permission,size,date,name --date=relative --total-size --group-dirs first" set in my .bashrc.

  • When \ls -lA is run:
total 1860
-rw-------  1 u0_a227 u0_a227     130 Mar 24 02:43 .bashrc
drwx------  9 u0_a227 u0_a227    3488 Mar 25 11:13 .config
lrwxrwxrwx  1 u0_a227 u0_a227      30 Mar 24 12:47 .gitconfig -> projects/dotFiles/.gitconfig
lrwxrwxrwx  1 u0_a227 u0_a227      30 Mar 24 12:47 .gitignore -> projects/dotFiles/.gitignore
drwx------  3 u0_a227 u0_a227    3488 Mar 24 02:44 .local
drwx------  2 u0_a227 u0_a227    3488 Mar 24 02:20 .ssh
drwx------  2 u0_a227 u0_a227    3488 Mar 25 10:20 .termux
lrwxrwxrwx  1 u0_a227 u0_a227      30 Mar 24 12:44 .zshenv -> projects/dotFiles/.zshenv
-rw-------  1 u0_a227 u0_a227 1826994 Mar 24 02:26 Screenshot_20210323-093654.png
drwx------  2 u0_a227 u0_a227    3488 Mar 24 02:30 bin
-rw-------  1 u0_a227 u0_a227      26 Mar 24 02:24 npmpackages.txt
-rw-------  1 u0_a227 u0_a227      45 Mar 24 02:24 pippackages.txt
-rw-------  1 u0_a227 u0_a227      44 Mar 24 02:24 pipxpackages.txt
-rw-------  1 u0_a227 u0_a227    2412 Mar 24 02:24 pkgInstall.txt
drwx------  3 u0_a227 u0_a227    3488 Mar 24 12:33 projects
drwx------  9 u0_a227 u0_a227    3488 Mar 25 10:08 rootofpi.me
drwx------  2 u0_a227 u0_a227    3488 Mar 23 23:54 storage
-rw-------  1 u0_a227 u0_a227    6283 Mar 24 02:26 termuxGstylus.key
-rw-------  1 u0_a227 u0_a227    6813 Mar 24 02:26 termuxSecretGstylus.key
-rw-------  1 u0_a227 u0_a227     937 Mar 24 02:24 title.txt
drwx------ 10 u0_a227 u0_a227    3488 Mar 25 11:23 tmp
  • and, for general reference, the lsd -la output without aliases set:
drwxr-xr-x pi   pi    64 MB Thu Mar 25 12:02:16 2021  ./                         drwxr-xr-x root root  64 MB Mon Jan 11 06:52:47 2021  ../                        drwx------ pi   pi   1.1 MB Tue Mar 23 18:47:58 2021  .cache/                    drwxr-xr-x pi   pi    42 KB Mon Mar 22 20:05:40 2021  .config/                   drwx------ pi   pi    21 KB Sun Mar 21 11:55:11 2021  .gnupg/                    drwx------ pi   pi   8.0 MB Thu Mar 25 09:53:12 2021  .local/                    drwxr-xr-x pi   pi   8.0 KB Sun Mar 21 07:26:00 2021  .neomutt/
drwx------ pi   pi   151 KB Tue Mar 23 09:38:46 2021  .password-store/           drwx------ pi   pi   5.3 KB Mon Mar 22 09:13:16 2021  .ssh/                      drwxr-xr-x pi   pi   4.0 KB Thu Mar 25 10:28:46 2021  .tmp/                      drwxr-xr-x pi   pi    12 MB Mon Mar 22 14:09:20 2021  bin/                       drwxr-x--- pi   pi    40 KB Tue Mar 23 02:24:52 2021  envs.net/                  drwxr-xr-x pi   pi    16 MB Mon Mar 22 09:18:49 2021  homePage/
drwx------ pi   pi   4.0 KB Sun Mar 21 07:06:27 2021  Mail/                      drwxr-xr-x pi   pi    27 MB Thu Mar 25 10:32:28 2021  termuxBU/
.rw-r--r-- pi   pi   483 B  Thu Mar 25 12:35:26 2021  .bash_aliases              .rw-r--r-- pi   pi   657 B  Tue Mar 23 19:03:00 2021  .bash_env
.rw------- pi   pi   9.3 KB Thu Mar 25 12:35:31 2021  .bash_history              .rw-r--r-- pi   pi   220 B  Mon Jan 11 06:52:47 2021  .bash_logout
.rw-r--r-- pi   pi   4.0 KB Thu Mar 25 10:48:47 2021  .bashrc                    .rw-r--r-- pi   pi   954 B  Thu Mar 25 09:52:46 2021  .profile
.rw-r--r-- pi   pi   2.6 KB Sun Mar 21 10:30:26 2021  .tmux.conf
.rw-r--r-- pi   pi   743 B  Sun Mar 21 02:46:56 2021  .zshenv                    .rw-r--r-- pi   pi   830 B  Sun Mar 21 03:11:24 2021  .zshrc
.rw-r--r-- pi   pi   2.4 KB Sun Mar 21 11:48:10 2021  alephalpha0.key            .rw-r--r-- pi   pi   172 B  Sun Mar 21 09:54:06 2021  TODO.md

Actual behavior

With both aliases set in .bashrc: Screenshot_20210325-124256

Is it because I have lsd set as alias before the ls alias?

alephalpha0 avatar Mar 25 '21 17:03 alephalpha0

hi @alephalpha0 It is happy to see that lsd runs on an Android device!

I have tried to reproduce your case and found that:

  1. yes, it is because you set lsd as an alias before the ls, and the aliased ls is expanded to something like lsd --blocks=permission,size,date,name --blocks=permission,size,date,name
  2. we append all the block options and show them together.

for your case, you can try to escape the lsd in ls alias, notice the \:

alias ls="\lsd -lAF --blocks=permission,size,date,name --date=relative --total-size --group-dirs first"

and it is also a funny case, @meain

  1. I insist on my point on keeping the duplicated options ONE --blocks option
  2. Maybe it is worth discussing how we handle multiple --blocks options

zwpaper avatar Mar 26 '21 07:03 zwpaper

I guess the ideal option would be only consider the last --blocks option.

For example if the user specifies lsd --block name,date --block permission,name we should use permission,name as the block. I remember me trying to do that and clap was either doing name,date,permission,name or just giving an error saying you can only specify blocks once. I did not look much deeper into this back then, but I think if we can take just the blocks specified in the last set, that would be better.

meain avatar Mar 27 '21 04:03 meain