colorls icon indicating copy to clipboard operation
colorls copied to clipboard

Make `colorls` a drop-in replacement for `ls`

Open avdv opened this issue 6 years ago • 12 comments

As time goes by, there are more and more command line options that differ from "standard" ls which makes it harder to switch to colorls (re-learn things and change old habits).

It would be nice, IMHO, if both tools would share the most common options and only diverge when necessary.

  • [x] remove multi-character short options (-sd and -sf)
  • [ ] (re-)move short options that have a different meaning in regard to ls (-h, -r, -f, -d)
  • [ ] accept most ls options, but ignore them if not relevant to colorls
  • [x] allow specifying mutual exclusive options without issue warnings

What do you think?

avdv avatar Aug 17 '17 19:08 avdv

Default ls doesn't even have -sd/-sf (at least /usr/bin/ls on my machine)

KSXGitHub avatar Aug 19 '17 12:08 KSXGitHub

@avdv @KSXGitHub - Sorry for the late reply. I usually reply within hours, but I somehow missed this issue discussion. 😬

Ideologically, I think that it's fine for colorls to have some features that aren't part of ls - though the same flags shouldn't mean two different things in ls and colorls. So, regarding your queries -

  1. -sd / -sf should be moved to some other flag (say, -D / -F) rather than get removed.
  2. -h, -r, -f, -d should also probably just be moved and not removed.
  3. Of course, with continuous development to support ls flags in colorls.

Though, this is an obvious concern that I've with moving the existing flags to new flags that don't clash with other functionality flags of ls : Break backward compatibility? Any user running a previous version would be accustomed to use -sd / -sf / ..., and all this would change on updating the gem. As a current user, would you rather prefer this?

One workaround is to add these in the post-install messages of the gem. But is this good enough?

athityakumar avatar Aug 22 '17 15:08 athityakumar

@athityakumar I think post-install message is a good idea. I also think that you should not remove old flags so quickly, instead, deprecate the use of non-standard flags (warn/prevent users from using them and recommend new flags instead).

Regarding -sd and -sf, they should be renamed to --sd/--sort-dir and --sf/--sort-files, not -D nor -F (ls has used -D and -F options)

KSXGitHub avatar Aug 22 '17 16:08 KSXGitHub

Regarding -sd and -sf, they should be renamed to --sd/--sort-dir and --sf/--sort-files, not -D nor -F (ls has used -D and -F options)

Yeah, good idea! I think we are on the same page then... 😄

avdv avatar Aug 24 '17 13:08 avdv

@avdv @KSXGitHub - Sure, let's go ahead with renaming -sd / -sf to --sd / --sf. 👍

athityakumar avatar Aug 24 '17 13:08 athityakumar

I also noticed you cannot combine -l and -a into -la in colorls, while I can do that in ls. Not sure if you can do this with other flags as well, but would be nice to have!

AlexanderArvidsson avatar Oct 01 '17 14:10 AlexanderArvidsson

If colorls should become a drop-in replacement for ls I think the current flag system is incorrect. ls uses flags as attributes, one letter per 'option'. As such you can mix and match any attribute and get different results, while in colorls you have to use specific flags. That means -la or -al would require two different flags in colorls to display all files as a list (attributes l for list, a for all). Right now you have to do colorls -l -a to get the same functionality as ls -la or ls -al. I think it makes sense to change the current system to match ls attributes.

AlexanderArvidsson avatar Oct 06 '17 11:10 AlexanderArvidsson

@Metamist - Hmm, alright. Support for clubbing various options like colorls -la can be provided easily, if these option short-hands are ALL single-letter only. I think that the current flag system would rather be easier to provide support for clubbed short-hands (like -la). Would you like to work on adding support to clubbed flags? 😄

@avdv @KSXGitHub - I think that once the -sd -> -D, -sf -> -F changes are done, adding support to clubbed flags should be the next point to focus.

athityakumar avatar Oct 06 '17 13:10 athityakumar

@athityakumar, I would be happy to work on it, however in order to provide colorls as a drop-in replacement for ls we need to get rid of flags longer than 1 character, such as -sd since it would conflict with the clubbed flag -lasd (is it -sd or -d, same example given in #74). Alternatively, we could only club flags that specified short-handed (prefixed with -) and leave flags with -- alone. -sd would then only be specified with --sort-dirs. If -sd and -sf are already being replaced, that's okay, but then we still have -gs to change as well. I'm not too used to ruby, but I could give it a try since it seems that the other issue hasn't had much activity and I honestly need this.

AlexanderArvidsson avatar Oct 06 '17 14:10 AlexanderArvidsson

@Metamist - Good to hear that you're interested in working on this. 😄

So, yes - each flag short-hand SHOULD have only one character. But, I (and hopefully many people) am using -sd as the default setting and wouldn't like such multi-character flags to be dropped. How about renaming them (like -D) instead? Then, clubbings like -laD could be handled easily with a simple logic of checking for individual tags if any tag has more than 1 character.

athityakumar avatar Oct 06 '17 14:10 athityakumar

@athityakumar, If they're being renamed to -D and -F that's alright to me. -sd can be both -D and --sd, and -sf should be -F and --sf in order to allow you to club it with other flags. But is -gs also being replaced with a -- command or a single-character command?

AlexanderArvidsson avatar Oct 06 '17 14:10 AlexanderArvidsson

Okay, upon rethinking about it. it seems more simpler (KISS) to me to just leave the multi-character flags as it is. Like, -sd -> --sd, -sf -> --sf and -gs -> --gs. And rest of the single-character flags can be clubbed like -la.

athityakumar avatar Oct 06 '17 14:10 athityakumar