coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: icon support for ls


From: Gokcehan Kara
Subject: Re: icon support for ls
Date: Tue, 15 May 2018 23:30:09 +0300

Cool hack indeed. It never occurred to me that this may already be
working. Although line wrapping does not work nicely in my terminal. I
guess this is what you mean by alignment consideration.

Also, I could not find a way to set the following entries in your
example using `dircolors`:

    LS_COLORS='lc=:rc=:rs=:'

In the source I see the following values are used:

    $LS_COLORS  dircolors               default
    lc          LEFT  (also LEFTCODE)   \033[
    rc          RIGHT (also RIGHTCODE)  m
    rs          RESET                   0

In dircolors configuration file, I tried to set these values to empty as
such:

    ...
    LEFT
    RIGHT
    RESET
    ...

But then the file is not parsed correctly and I get the following
errors:

    dircolors: .dircolors:44: invalid line;  missing second token
    dircolors: .dircolors:45: invalid line;  missing second token
    dircolors: .dircolors:46: invalid line;  missing second token

Another problem is that when these values are set to empty, one needs to
manually add these to color codes if s/he wants to use colors and icons
at the same time. It may not be desirable to have escape characters in
the configuration file and the environmental variable.

Alternatively, I was thinking this could be implemented by adding an
optional third column to `dircolors` entries. This has the advantage of
being backwards compatible as well. `$LS_COLORS` variable needs to adopt
a similar strategy to have optional icon values in the entries which may
require an additional separator:

    ... :di=01;34|D: ...

    ('|' is used as the separator and 'D' is used as the icon)

On the `ls` side, I guess these icon values need to be considered to
calculate filename lenghts properly for the alignment. Maybe icons can
be limited to 1 or 2 characters which should be fine for most cases.

Gokcehan


On Tue, May 15, 2018 at 8:32 AM, PΓ‘draig Brady <address@hidden> wrote:

> On 14/05/18 15:07, Gokcehan Kara wrote:
> > Hello,
> >
> > Apologies if this has been discussed before.
> >
> > There has been some interest for showing icons for different files in
> `ls`
> > lately. I have found the following projects attempting this:
> >
> >     https://github.com/illinoisjackson/better-ls/
> >     https://github.com/ryanoasis/devicons-shell
> >     https://github.com/athityakumar/colorls
> >
> > There are some others trying to modify `ls` source for this purpose:
> >
> >     https://github.com/illinoisjackson/even-better-ls
> >     https://github.com/sebastiencs/ls-icons
> >
> > Though I doubt these have been submitted back as patches.
> >
> > There are already some interesting unicode icons in the standard:
> >
> >     πŸ—€ Folder         U+1F5C0
> >     πŸ— Open Folder    U+1F5C1
> >     πŸ—‹ Empty Document U+1F5CB
> >     πŸ—Œ Empty Page     U+1F5CC
> >     πŸ— Empty Pages    U+1F5CD
> >     πŸ—Ž Document       U+1F5CE
> >     πŸ— Page           U+1F5CF
> >     πŸ— Pages          U+1F5D0
> >
> > There are also specialized fonts with support for various icons:
> >
> >     https://github.com/ryanoasis/nerd-fonts
> >     https://github.com/sebastiencs/icons-in-terminal
> >
> > I was thinking a similar mechanism as the color option could be used for
> > icons
> > as well. Maybe `dircolors` can be used to export an `$LS_ICONS` variable
> > from a
> > configuration file. Or maybe this could be directly added to `$LS_COLORS`
> > variable somehow.
> >
> > What do you think such a feature?
>
> An interesting proposal, though less general on the terminal due
> to space available and alignment considerations.
>
> Note you can sort of hack it now with LS_COLORS like:
>
> LS_COLORS='lc=:rc=:rs=:'
> LS_COLORS="${LS_COLORS}di=πŸ—€ :fi=πŸ—‹ :ln=  :do=  :cd=  :bd=  :so=  :pi=  :"
> LS_COLORS="${LS_COLORS}ex=:tw=:ow=:st=:su=:sg=:"
> export LS_COLORS
>
> Which generates nicely aligned output on my terminal at least:
> For example: ls /proc/$$
>
> πŸ—€ attr               cwd      πŸ—‹ loginuid    πŸ—‹ numa_maps      πŸ—‹
> schedstat  πŸ—€ task
> πŸ—‹ autogroup        πŸ—‹ environ  πŸ—€ map_files   πŸ—‹ oom_adj        πŸ—‹
> sessionid  πŸ—‹ timers
> πŸ—‹ auxv               exe      πŸ—‹ maps        πŸ—‹ oom_score      πŸ—‹
> setgroups  πŸ—‹ timerslack_ns
> πŸ—‹ cgroup           πŸ—€ fd       πŸ—‹ mem         πŸ—‹ oom_score_adj  πŸ—‹ smaps
>     πŸ—‹ uid_map
> πŸ—‹ clear_refs       πŸ—€ fdinfo   πŸ—‹ mountinfo   πŸ—‹ pagemap        πŸ—‹ stack
>     πŸ—‹ wchan
> πŸ—‹ cmdline          πŸ—‹ gid_map  πŸ—‹ mounts      πŸ—‹ personality    πŸ—‹ stat
> πŸ—‹ comm             πŸ—‹ io       πŸ—‹ mountstats  πŸ—‹ projid_map     πŸ—‹ statm
> πŸ—‹ coredump_filter  πŸ—‹ latency  πŸ—€ net           root           πŸ—‹ status
> πŸ—‹ cpuset           πŸ—‹ limits   πŸ—€ ns          πŸ—‹ sched          πŸ—‹ syscall
>
> cheers,
> PΓ‘draig
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]