[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
>