kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.79k stars 961 forks source link

File types are not color coded #748

Closed ccaneke closed 6 years ago

ccaneke commented 6 years ago

I noticed that compared to genome-terminal that file types in kitty are not color coded. Instead all text displays in white unless I am using grep. In gnome-terminal, directories are blue, executables green and sym links turquoise. I expected to see the same in kitty. Is this feature turned off by default in kitty? If so how do I enable it?

kovidgoyal commented 6 years ago

This is not a feature of your terminal, but of whatever program you are using to list files. If you are using ls use ls --color=always or ls --color=auto

ccaneke commented 6 years ago

@kovidgoyal Right, I am using ls to list files. Where in the kitty config file can I add ls --color=always or ls --color=auto to make it persistant? May be even an environment variable for kitty.

kovidgoyal commented 6 years ago

That is not something you add in the terminal emulator config, it is something you add in the shell config

ccaneke commented 6 years ago

Thanks for pointing me in the right direction @kovidgoyal . I have now created aliases for ls, tree and less to always show colors. Though there are one or two strange observations - zipped files are still colorless where as they should be red, and executables are not green when pointed to from a symlink e.g:

[user@host ~]$ ls -l /usr/local/bin
total 4
-rwxrwxr--. 1 user group 104 Jul 23 21:30 kitty
lrwxrwxrwx. 1 user group  36 Jul 14 12:26 symlink -> /Path/to/target/executable/file

/Path/to/target/executable/file is green in gnome-terminal

maximbaz commented 6 years ago

The colors depend on LS_COLORS environment variable, you can configure it to your liking.

I use this one: https://github.com/trapd00r/LS_COLORS

image

kovidgoyal commented 6 years ago

As @maximbaz said, though IIRC if you want to use a dircolors file, remember to add TERM=xterm-kitty at the end, otherwise dircolors will not output the proper color codes.

kovidgoyal commented 6 years ago

@maximbaz personally, I hate having such large environment variables, its a waste as it means it has to be copied into the process space of every new process. Instead I like ot create a ~/bin/ls like this:

#!/bin/sh

eval $(dircolors -b ~/.dircolors)
exec /bin/ls "$@"

So only ls is affected by it.

maximbaz commented 6 years ago

Interesting approach!

kovidgoyal commented 6 years ago

And just to avoid calling dircolors when stdout is not a terminal:

#!/bin/sh

if [ -t 1 ]; then
    eval $(dircolors -b ~/work/env/conf/dircolors)
fi
exec /bin/ls "$@"
ccaneke commented 6 years ago

I just found another; *.png files are not colored as well. This suggests only directory colors are being resolved. I suspect kitty is not inheriting the default colors for ls the same way gnome-terminal is, for some reason.

@maximbaz I had a brief look at that github repo previously and its seems like an option. I also I like @kovidgoyal approach because it avoids bloat. However @kovidgoyal isn't the __LS_COLORS__ envirionment variable copied for every process only when it is added to .bashrc. If it was added to .profile then would it not be exported only once for all processes at login?

ccaneke commented 6 years ago

Also, am I right to think that your second command means that there would be no colors for a pager such as less since that command is only true when stdout is a terminal?

I don't have a .dircolors file. Is this something you created?

kovidgoyal commented 6 years ago

If you put something into the environment of a shell, then any process launched by that shell will inherit that environment, and any process launched by any of those processes will inherit that environment and on and on.

And less does not use LS_COLORS only ls uses them. If you want to setup colors for less it has its own environment variables. Why all these utilities couldn't use config files I'll never know. If you mean you want to pipe the output of less into less, then yes, it wont work. It is essentially the same as foing --color-auto.

As for the difference between kitty and gnome-terminal, it will be because your system likely already uses a dircolors script that hardcodes a value of TERM for gnome-terminal.

ccaneke commented 6 years ago

Thanks @kovidgoyal , its a lot clearer now, and you're right, I did find a __dir_colors__ file (three actually) with gnome and many other terminals. Kitty must be really new since its not in those files.

I have a question about your solution in the second command you posted. When you say you created the ls command in your $HOME directory, do you mean that you just copied the already existing one from /usr/bin or did you actually create it from scratch?

If you did just create it from scratch, then can I just run exec /usr/bin/ls to execute the already existing ls as an alternative.

kovidgoyal commented 6 years ago

It is a launcher script to set the LS_COLORS env var and run /bin/ls afterwards

ccaneke commented 6 years ago

Thanks @kovidgoyal , I came to that conclusion soon after asking. However, I implemented your solution in these steps and its not working:

  1. Downloaded LS_COLORS to `~/.dircolors
  2. Added TERM=xterm-kitty where all the other TERM variables were defined in .dircolors
  3. Created a launcher script in ~/bin/ls
  4. Populated this launcher script with the shebang, eval to pass the strings in bracket to the shell and exec to replace all processes with just the ls process.
  5. Made the ~/bin/ls file executable.

The man page for __dir_colors__ says

Usually, the file used here is /etc/DIR_COLORS and can be overridden by a .dir_colors file in one's home directory.

Would this be why its not working?

Just to mention, I also have an alias for ls set as alias ls = "ls --color" andecho LS_COLORS` shows nothing.

kovidgoyal commented 6 years ago

You also have to add ~/bin to PATH

ccaneke commented 6 years ago

I checked $PATH and you've just given me a big hint. My $PATH shows that ~/bin is already added, but it comes last in the $PATH list. I strongly believe that because ~/bin comes after /bin that bash uses the first ls it sees.

Also, /bin is not a directory, it's a symbolic link to /usr/bin and it is not in $PATH UPDATE: Moving the ls script to a directory that is before /usr/bin did not change anything.

ccaneke commented 6 years ago

So I got it to work, it struggles to show colors correctly though and I am not getting the full range of colors shown in @maximbaz screenshot. For example, executables and symlinks have the same color, and file permissions are still colorless.

@kovidgoyal shouldn't it be xterm-kitty-256color for the TERM variable since I suppose kitty supports 256 colors?

maximbaz commented 6 years ago

I'm using https://github.com/trapd00r/LS_COLORS, are you?

ccaneke commented 6 years ago

Yes @maximbaz. I am using the same LS_COLORS from your link.

Are you using xterm-kitty or xterm-kitty-256colors for the TERM variable?

This is what echo $LS_COLORS gives:

bd=38;5;68:ca=38;5;17:cd=38;5;113;1:di=38;5;30:do=38;5;127:ex=38;5;208;1:pi=38;5;126:fi=0:ln=target:mh=38;5;222;1:no=0:or=48;5;196;38;5;232;1:ow=38;5;220;1:sg=48;5;3;38;5;0:su=38;5;220;1;3;100;1:so=38;5;197:st=38;5;86;48;5;234:tw=48;5;235;38;5;139;3:*LS_COLORS=48;5;89;38;5;197;1;3;4;7:*README=38;5;220;1:*README.rst=38;5;220;1:*LICENSE=38;5;220;1:*COPYING=38;5;220;1:*INSTALL=38;5;220;1:*COPYRIGHT=38;5;220;1:*AUTHORS=38;5;220;1:*HISTORY=38;5;220;1:*CONTRIBUTORS=38;5;220;1:*PATENTS=38;5;220;1:*VERSION=38;5;220;1:*NOTICE=38;5;220;1:*CHANGES=38;5;220;1:*.log=38;5;190:*.txt=38;5;253:*.etx=38;5;184:*.info=38;5;184:*.markdown=38;5;184:*.md=38;5;184:*.mkd=38;5;184:*.nfo=38;5;184:*.pod=38;5;184:*.rst=38;5;184:*.tex=38;5;184:*.textile=38;5;184:*.json=38;5;178:*.msg=38;5;178:*.pgn=38;5;178:*.rss=38;5;178:*.xml=38;5;178:*.yaml=38;5;178:*.yml=38;5;178:*.RData=38;5;178:*.rdata=38;5;178:*.cbr=38;5;141:*.cbz=38;5;141:*.chm=38;5;141:*.djvu=38;5;141:*.pdf=38;5;141:*.PDF=38;5;141:*.docm=38;5;111;4:*.doc=38;5;111:*.docx=38;5;111:*.eps=38;5;111:*.ps=38;5;111:*.odb=38;5;111:*.odt=38;5;111:*.rtf=38;5;111:*.odp=38;5;166:*.pps=38;5;166:*.ppt=38;5;166:*.pptx=38;5;166:*.ppts=38;5;166:*.pptxm=38;5;166;4:*.pptsm=38;5;166;4:*.csv=38;5;78:*.ods=38;5;112:*.xla=38;5;76:*.xls=38;5;112:*.xlsx=38;5;112:*.xlsxm=38;5;112;4:*.xltm=38;5;73;4:*.xltx=38;5;73:*cfg=1:*conf=1:*rc=1:*.ini=1:*.plist=1:*.viminfo=1:*.pcf=1:*.psf=1:*.git=38;5;197:*.gitignore=38;5;240:*.gitattributes=38;5;240:*.gitmodules=38;5;240:*.awk=38;5;172:*.bash=38;5;172:*.bat=38;5;172:*.BAT=38;5;172:*.sed=38;5;172:*.sh=38;5;172:*.zsh=38;5;172:*.vim=38;5;172:*.ahk=38;5;41:*.py=38;5;41:*.pl=38;5;208:*.PL=38;5;160:*.t=38;5;114:*.msql=38;5;222:*.mysql=38;5;222:*.pgsql=38;5;222:*.sql=38;5;222:*.tcl=38;5;64;1:*.r=38;5;49:*.R=38;5;49:*.gs=38;5;81:*.asm=38;5;81:*.cl=38;5;81:*.lisp=38;5;81:*.lua=38;5;81:*.moon=38;5;81:*.c=38;5;81:*.C=38;5;81:*.h=38;5;110:*.H=38;5;110:*.tcc=38;5;110:*.c++=38;5;81:*.h++=38;5;110:*.hpp=38;5;110:*.hxx=38;5;110:*.ii=38;5;110:*.M=38;5;110:*.m=38;5;110:*.cc=38;5;81:*.cs=38;5;81:*.cp=38;5;81:*.cpp=38;5;81:*.cxx=38;5;81:*.cr=38;5;81:*.go=38;5;81:*.f=38;5;81:*.for=38;5;81:*.ftn=38;5;81:*.s=38;5;110:*.S=38;5;110:*.rs=38;5;81:*.swift=38;5;219:*.sx=38;5;81:*.hi=38;5;110:*.hs=38;5;81:*.lhs=38;5;81:*.pyc=38;5;240:*.css=38;5;125;1:*.less=38;5;125;1:*.sass=38;5;125;1:*.scss=38;5;125;1:*.htm=38;5;125;1:*.html=38;5;125;1:*.jhtm=38;5;125;1:*.mht=38;5;125;1:*.eml=38;5;125;1:*.mustache=38;5;125;1:*.coffee=38;5;074;1:*.java=38;5;074;1:*.js=38;5;074;1:*.mjs=38;5;074;1:*.jsm=38;5;074;1:*.jsm=38;5;074;1:*.jsp=38;5;074;1:*.php=38;5;81:*.ctp=38;5;81:*.twig=38;5;81:*.vb=38;5;81:*.vba=38;5;81:*.vbs=38;5;81:*Dockerfile=38;5;155:*.dockerignore=38;5;240:*Makefile=38;5;155:*MANIFEST=38;5;243:*pm_to_blib=38;5;240:*.am=38;5;242:*.in=38;5;242:*.hin=38;5;242:*.scan=38;5;242:*.m4=38;5;242:*.old=38;5;242:*.out=38;5;242:*.SKIP=38;5;244:*.diff=48;5;197;38;5;232:*.patch=48;5;197;38;5;232;1:*.bmp=38;5;97:*.tiff=38;5;97:*.tif=38;5;97:*.TIFF=38;5;97:*.cdr=38;5;97:*.gif=38;5;97:*.ico=38;5;97:*.jpeg=38;5;97:*.JPG=38;5;97:*.jpg=38;5;97:*.nth=38;5;97:*.png=38;5;97:*.psd=38;5;97:*.xpm=38;5;97:*.ai=38;5;99:*.eps=38;5;99:*.epsf=38;5;99:*.drw=38;5;99:*.ps=38;5;99:*.svg=38;5;99:*.avi=38;5;114:*.divx=38;5;114:*.IFO=38;5;114:*.m2v=38;5;114:*.m4v=38;5;114:*.mkv=38;5;114:*.MOV=38;5;114:*.mov=38;5;114:*.mp4=38;5;114:*.mpeg=38;5;114:*.mpg=38;5;114:*.ogm=38;5;114:*.rmvb=38;5;114:*.sample=38;5;114:*.wmv=38;5;114:*.3g2=38;5;115:*.3gp=38;5;115:*.gp3=38;5;115:*.webm=38;5;115:*.gp4=38;5;115:*.asf=38;5;115:*.flv=38;5;115:*.ts=38;5;115:*.ogv=38;5;115:*.f4v=38;5;115:*.VOB=38;5;115;1:*.vob=38;5;115;1:*.3ga=38;5;137;1:*.S3M=38;5;137;1:*.aac=38;5;137;1:*.au=38;5;137;1:*.dat=38;5;137;1:*.dts=38;5;137;1:*.fcm=38;5;137;1:*.m4a=38;5;137;1:*.mid=38;5;137;1:*.midi=38;5;137;1:*.mod=38;5;137;1:*.mp3=38;5;137;1:*.mp4a=38;5;137;1:*.oga=38;5;137;1:*.ogg=38;5;137;1:*.opus=38;5;137;1:*.s3m=38;5;137;1:*.sid=38;5;137;1:*.wma=38;5;137;1:*.ape=38;5;136;1:*.aiff=38;5;136;1:*.cda=38;5;136;1:*.flac=38;5;136;1:*.alac=38;5;136;1:*.midi=38;5;136;1:*.pcm=38;5;136;1:*.wav=38;5;136;1:*.wv=38;5;136;1:*.wvc=38;5;136;1:*.afm=38;5;66:*.fon=38;5;66:*.fnt=38;5;66:*.pfb=38;5;66:*.pfm=38;5;66:*.ttf=38;5;66:*.otf=38;5;66:*.PFA=38;5;66:*.pfa=38;5;66:*.7z=38;5;40:*.a=38;5;40:*.arj=38;5;40:*.bz2=38;5;40:*.cpio=38;5;40:*.gz=38;5;40:*.lrz=38;5;40:*.lz=38;5;40:*.lzma=38;5;40:*.lzo=38;5;40:*.rar=38;5;40:*.s7z=38;5;40:*.sz=38;5;40:*.tar=38;5;40:*.tgz=38;5;40:*.xz=38;5;40:*.z=38;5;40:*.Z=38;5;40:*.zip=38;5;40:*.zipx=38;5;40:*.zoo=38;5;40:*.zpaq=38;5;40:*.zz=38;5;40:*.apk=38;5;215:*.deb=38;5;215:*.rpm=38;5;215:*.jad=38;5;215:*.jar=38;5;215:*.cab=38;5;215:*.pak=38;5;215:*.pk3=38;5;215:*.vdf=38;5;215:*.vpk=38;5;215:*.bsp=38;5;215:*.dmg=38;5;215:*.r[0-9]{0,2}=38;5;239:*.zx[0-9]{0,2}=38;5;239:*.z[0-9]{0,2}=38;5;239:*.part=38;5;239:*.dmg=38;5;124:*.iso=38;5;124:*.bin=38;5;124:*.nrg=38;5;124:*.qcow=38;5;124:*.sparseimage=38;5;124:*.toast=38;5;124:*.vcd=38;5;124:*.vmdk=38;5;124:*.accdb=38;5;60:*.accde=38;5;60:*.accdr=38;5;60:*.accdt=38;5;60:*.db=38;5;60:*.fmp12=38;5;60:*.fp7=38;5;60:*.localstorage=38;5;60:*.mdb=38;5;60:*.mde=38;5;60:*.sqlite=38;5;60:*.typelib=38;5;60:*.nc=38;5;60:*.pacnew=38;5;33:*.un~=38;5;241:*.orig=38;5;241:*.BUP=38;5;241:*.bak=38;5;241:*.o=38;5;241:*.rlib=38;5;241:*.swp=38;5;244:*.swo=38;5;244:*.tmp=38;5;244:*.sassc=38;5;244:*.pid=38;5;248:*.state=38;5;248:*lockfile=38;5;248:*.err=38;5;160;1:*.error=38;5;160;1:*.stderr=38;5;160;1:*.dump=38;5;241:*.stackdump=38;5;241:*.zcompdump=38;5;241:*.zwc=38;5;241:*.pcap=38;5;29:*.cap=38;5;29:*.dmp=38;5;29:*.DS_Store=38;5;239:*.localized=38;5;239:*.CFUserTextEncoding=38;5;239:*.allow=38;5;112:*.deny=38;5;196:*.service=38;5;45:*@.service=38;5;45:*.socket=38;5;45:*.swap=38;5;45:*.device=38;5;45:*.mount=38;5;45:*.automount=38;5;45:*.target=38;5;45:*.path=38;5;45:*.timer=38;5;45:*.snapshot=38;5;45:*.application=38;5;116:*.cue=38;5;116:*.description=38;5;116:*.directory=38;5;116:*.m3u=38;5;116:*.m3u8=38;5;116:*.md5=38;5;116:*.properties=38;5;116:*.sfv=38;5;116:*.srt=38;5;116:*.theme=38;5;116:*.torrent=38;5;116:*.urlview=38;5;116:*.asc=38;5;192;3:*.bfe=38;5;192;3:*.enc=38;5;192;3:*.gpg=38;5;192;3:*.signature=38;5;192;3:*.sig=38;5;192;3:*.p12=38;5;192;3:*.pem=38;5;192;3:*.pgp=38;5;192;3:*.asc=38;5;192;3:*.enc=38;5;192;3:*.sig=38;5;192;3:*.32x=38;5;213:*.cdi=38;5;213:*.fm2=38;5;213:*.rom=38;5;213:*.sav=38;5;213:*.st=38;5;213:*.a00=38;5;213:*.a52=38;5;213:*.A64=38;5;213:*.a64=38;5;213:*.a78=38;5;213:*.adf=38;5;213:*.atr=38;5;213:*.gb=38;5;213:*.gba=38;5;213:*.gbc=38;5;213:*.gel=38;5;213:*.gg=38;5;213:*.ggl=38;5;213:*.ipk=38;5;213:*.j64=38;5;213:*.nds=38;5;213:*.nes=38;5;213:*.sms=38;5;213:*.pot=38;5;7:*.pcb=38;5;7:*.mm=38;5;7:*.pod=38;5;7:*.gbr=38;5;7:*.spl=38;5;7:*.scm=38;5;7:*.Rproj=38;5;11:*.sis=38;5;7:*.1p=38;5;7:*.3p=38;5;7:*.cnc=38;5;7:*.def=38;5;7:*.ex=38;5;7:*.example=38;5;7:*.feature=38;5;7:*.ger=38;5;7:*.map=38;5;7:*.mf=38;5;7:*.mfasl=38;5;7:*.mi=38;5;7:*.mtx=38;5;7:*.pc=38;5;7:*.pi=38;5;7:*.plt=38;5;7:*.pm=38;5;7:*.rb=38;5;7:*.rdf=38;5;7:*.rst=38;5;7:*.ru=38;5;7:*.sch=38;5;7:*.sty=38;5;7:*.sug=38;5;7:*.t=38;5;7:*.tdy=38;5;7:*.tfm=38;5;7:*.tfnt=38;5;7:*.tg=38;5;7:*.vcard=38;5;7:*.vcf=38;5;7:*.xln=38;5;7:*.iml=38;5;166:*.xcconfig=1:*.entitlements=1:*.strings=1:*.storyboard=38;5;196:*.xcsettings=1:*.xib=38;5;208:

kovidgoyal commented 6 years ago

Read the LS_COLORS file from that link, it defines LINK as TARGET which means LINK colors are set to target colors. So it was probably changed after maximbaz started using it.

maximbaz commented 6 years ago

I actually use exa instead of ls, and it seems it kinda respects LS_COLORS, but then makes additional color overrides to it. Never knew about this 🙂

So the fact that you see links colored as files is actually expected from that LS_COLORS provider.

image

Tab completion in zsh for example also respects LS_COLORS, and in here you can see that contrary to exa, links do have the same colors as the target:

image

P.S. My term variable is xterm-kitty.

ccaneke commented 6 years ago

I have exa as well but typing it is not as intuitive as ls, I'm probably going to make an alias for it. Thanks @kovidgoyal for pointing that out, I just realised it when looking through the output I posted.

ccaneke commented 6 years ago

@maximbaz what's the name of the theme your using for your terminal? The background and foreground colors look nice, and easy on the eyes.

maximbaz commented 6 years ago

It's gruvbox: https://github.com/maximbaz/dotfiles/blob/master/.config/kitty/kitty.conf

ccaneke commented 6 years ago

Thanks a lot. It looks like information about installation is about vim. How did you install it? I'm not sure which part of the repo to download, did you git clone and copy whatever you downloaded into kitty.conf?

maximbaz commented 6 years ago

Nothing to download, just see the link to my kitty.conf above and copy the bits about colors into your kitty.conf 🙂

ccaneke commented 6 years ago

Ahh I see, You caliberated your terminal with the same settings as gruvbox. Gruvbox is not like other themes I've seen where you have to install e.g. Dracula etc., it's more like a specification. Great work on the repo. @maximbaz I also noticed you are displaying a picture of a lake in your terminal without using kitty icat. How did you do this?

SolitudeSF commented 6 years ago

there's kitty image protocol support in ranger's master