Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Question Marks trying to enable icons #1159

Closed
madrigal1 opened this issue Mar 15, 2023 Discussed in #1158 · 24 comments
Closed

[BUG] Question Marks trying to enable icons #1159

madrigal1 opened this issue Mar 15, 2023 Discussed in #1158 · 24 comments

Comments

@madrigal1
Copy link

Discussed in #1158

Originally posted by madrigal1 March 15, 2023
image
icons file is the icons.example
set icons true is added in lfrc

@gokcehan
Copy link
Owner

@madrigal1 There is no such thing as set icons true. See #758 for more information.

Do you have nerd fonts installed?

@madrigal1
Copy link
Author

Ah a lot of new lf users come from popular youtubers which use the old commands and outdated syntax like the use icons true and using env variables to set the colors and icons thanks for clearing that up

@madrigal1
Copy link
Author

madrigal1 commented Mar 16, 2023

Yes i have nerd fonts installed:
image

image

@madrigal1
Copy link
Author

using the new documentation still doesn't fix the issue :
image

@madrigal1
Copy link
Author

still no icons :
image

to confirm i only need to add the icons file in the ~/config/lf/icons right ?
no additional command to be added in the lfrc ?

@madrigal1
Copy link
Author

@gokcehan any idea as to what i am missing ?

@madrigal1
Copy link
Author

set icons
set icons true
set icons on
<not including this in lfrc>

none of the above combinations work

@madrigal1
Copy link
Author

madrigal1 commented Mar 16, 2023

lfrc file :

# interpreter for shell commands
set shell sh
# set '-eu' options for shell commands
# These options are used to have safer shell commands. Option '-e' is used to
# exit on error and option '-u' is used to give error for unset variables.
# Option '-f' disables pathname expansion which can be useful when $f, $fs, and
# $fx variables contain names with '*' or '?' characters. However, this option
# is used selectively within individual commands as it can be limiting at
# times.
set shellopts '-eu'
#set icons true
# set internal field separator (IFS) to "\n" for shell commands
# This is useful to automatically split file names in $fs and $fx properly
# since default file separator used in these variables (i.e. 'filesep' option)
# is newline. You need to consider the values of these options and create your
# commands accordingly.
set ifs "\n"
# leave some space at the top and the bottom of the screen
set scrolloff 10
set icons
# Use the `dim` attribute instead of underline for the cursor in the preview pane
#set cursorpreviewfmt "\033[7;2m"

# use enter for shell commands
map <enter> shell

# execute current file (must be executable)
map x $$f
map X !$f

# dedicated keys for file opener actions
map o &mimeopen $f
map O $mimeopen --ask $f

# define a custom 'open' command
# This command is called when current file is not a directory. You may want to
# use either file extensions and/or mime types here. Below uses an editor for
# text files and a file opener for the rest.
cmd open &{{
    case $(file --mime-type -Lb $f) in
        text/*) lf -remote "send $id \$$EDITOR \$fx";;
        *) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;;
    esac
}}

# define a custom 'rename' command without prompt for overwrite
# cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
# map r push :rename<space>

# make sure trash folder exists
# %mkdir -p ~/.trash

# move current file or selected files to trash folder
# (also see 'man mv' for backup/overwrite options)
cmd trash %set -f; mv $fx ~/.trash

# define a custom 'delete' command
# cmd delete ${{
#     set -f
#     printf "$fx\n"
#     printf "delete?[y/n]"
#     read ans
#     [ "$ans" = "y" ] && rm -rf $fx
# }}

# use '<delete>' key for either 'trash' or 'delete' command
# map <delete> trash
# map <delete> delete

# extract the current file with the right command
# (xkcd link: https://xkcd.com/1168/)
cmd extract ${{
    set -f
    case $f in
        *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
        *.tar.gz|*.tgz) tar xzvf $f;;
        *.tar.xz|*.txz) tar xJvf $f;;
        *.zip) unzip $f;;
        *.rar) unrar x $f;;
        *.7z) 7z x $f;;
    esac
}}

# compress current file or selected files with tar and gunzip
cmd tar ${{
    set -f
    mkdir $1
    cp -r $fx $1
    tar czf $1.tar.gz $1
    rm -rf $1
}}

# compress current file or selected files with zip
cmd zip ${{
    set -f
    mkdir $1
    cp -r $fx $1
    zip -r $1.zip $1
    rm -rf $1
}}

#deleting things
map d # leave the command name empty like this for unmapping
map dd delete
#map dD $IFS=':'; rm -rf $fx
map dD ${{
    echo 'delete?[y/n]'
    read ans
    [ $ans = 'y' ] && echo 'deleting files..' || echo 'cancelled.'
}}

cmd remove ${{
    echo 'delete?[y/n]'
    read ans
    [ $ans = 'y' ] && echo 'deleting files..' || echo 'cancelled.'
}}
map dD push :remove

@madrigal1
Copy link
Author

i have also added lf_icons env var as fallback:
image

@gokcehan
Copy link
Owner

@madrigal1 You are right, you also need set icons in your lfrc file. I have now updated the wiki page accordingly.

Your latest screenshots do not seem to have set icons so I'm not sure what can be the problem this time.

@joelim-work
Copy link
Collaborator

There seems to be more than one issue here:

  • Enabling icons (they are disabled by default)
  • Displaying Nerd Fonts characters when icons are enabled

I think this would be easier to diagnose if you are able to reproduce from scratch, could you please try the following?

  1. Mention what version of lf you are using (or even better obtain the latest version by building from source)
  2. Backup then delete all your lf-related config
  3. Create an lfrc file containing nothing but set icons to enable the icons (as a side note you can also type :set icons/:set noicons in the command line to enable/disable icons while lf is running)
  4. Create an icons file containing nothing but fi  to ensure that Nerd Fonts icons work

I have never seen question marks as icons before - normally I would associate that with the terminal not being able to find or load the font, but that doesn't seem to be the case here. Also you wouldn't happen to be using a dotfile configuration manager and your config files just simply aren't synced?

@madrigal1
Copy link
Author

madrigal1 commented Mar 17, 2023

Thanks @joelim-work for the response.

  • changed lfrc to only set icons
    image

  • changed icons to only include fi
    image

*lf version
image

*result:
image

i am using the arch linux pkg :
https://archlinux.org/packages/community/x86_64/lf/

*neofetch
image

let me know if i can provide any additional info

@joelim-work
Copy link
Collaborator

OK so it looks like the set icons issue is resolved, not sure why it wasn't appearing earlier.

As for the question marks issue, I have some more questions:

  1. What happens when you don't configure any icons? Do you see question marks or the defaults (i.e. d for directories, - for files)?
  2. What happens if you change the icons file to use a regular character instead, something like fi F, do you start seeing F instead of question marks?
  3. I'm assuming your terminal can display the Nerd Fonts icons, but for some reason it doesn't work only when you are using lf? One thing I found interesting is that in the fourth screenshot you provided, the preview of the icons file says fi ?, so it seems like this isn't an issue with icons, but more of the ability of your terminal or lf to render this icon. I'm not sure if it will help, but would you be able to show a hexdump your icons file? Something like hexdump -C /path/to/icons should do. I hope this is not something like a file encoding issue.

@madrigal1
Copy link
Author

madrigal1 commented Mar 17, 2023

Thanks for the response @joelim-work:

  • hexdump
    image

  • removing icons and using :set icons in lf itself
    image

  • adding fi F shows F as the icon:
    image

  • am able to trigger the defaults after removing the LF_ICONS env variable:
    image

  • icons.example file config with LF_ICONS env var complelty removed:
    image

  • (icons file removed) and (lf_icons removed) and (set icons true in lfrc):
    image

  • logs don't show any errors:
    image

Does this indicate the issue is in parsing the icons file ?
i have used the one directly from here https://raw.githubusercontent.com/gokcehan/lf/master/etc/icons.example

@joelim-work
Copy link
Collaborator

So the hexdump looks right to me (UTF-8), shouldn't be a file encoding issue.

Judging from the evidence so far, the default icons do seem to work for you, and also setting fi F works. I'm starting to think the issue has nothing to do with icons, and just the way these characters are being rendered. For example, what happens if you create a file containing some of these characters and try to preview it? Also what happens if you type :echomsg  into the command line (it should display the text at the bottom, and it would also appear in the log file).

@madrigal1
Copy link
Author

madrigal1 commented Mar 17, 2023

Thanks for the response @joelim-work :
image

  • i use the set icons cmd manually and then echo msg
    image

  • icon pasted in terminal:
    image

  • icon after pasting directly in lf (as you can see it doesn't show up):
    image

looks like lf cannot render the icon ?

@joelim-work
Copy link
Collaborator

Yeah I think your issue has nothing to do with displaying file icons in lf, and is more to do with Go handling icon characters. The thing is, icons work perfectly fine for me and most other users too, maybe there's something strange about your system that is causing this? At this point I'm pretty much out of ideas though, apologies for not being more helpful. But we have narrowed down the issue a lot, hopefully @gokcehan or others might have an idea here?

Otherwise if you do want to go down the rabbit hole and have lots of spare time to play around with Go, there are further things you can try, such as building this project from source and inserting log.Printf statements into the code, or creating a hello world project in Go and seeing if you can print out those characters.

@madrigal1
Copy link
Author

madrigal1 commented Mar 17, 2023

Thanks @joelim-work. lf is blazing fast compared to ranger and i will continue to use it. it is a bummer not to have the icons. if you do think of a solution later on do post in the thread as it may help me and future users who may have similar issues. :-)

@gokcehan
Copy link
Owner

@madrigal1 @joelim-work Maybe this could be an encoding issue? Can you type locale in your terminal and paste the output here? Tcell only supports ascii and utf-8 encodings without registering any other encodings.

@madrigal1
Copy link
Author

madrigal1 commented Mar 17, 2023

Hey @gokcehan thanks for the response:

  • locale output
    image

  • this fix was suggested and i had implemented when i first searched google without much success. linking for future reference:

https://www.reddit.com/r/commandline/comments/ld8l6s/comment/i5uyp0z/?utm_source=share&utm_medium=web2x&context=3

  • ~/etc/locale.conf
    image

Any suggestions?

@gokcehan
Copy link
Owner

@madrigal1 Maybe you need to run locale-gen to update it afterwards though I'm not too familiar with these settings myself and I think it might depend on your system so you should better look it up from somewhere.

@joelim-work
Copy link
Collaborator

If you're using Manjaro, then that is based of Arch Linux and I think you can just follow the instructions. The file you define LANG in should be /etc/locale.conf, not ~/etc/locale.conf. And you also need to edit /etc/locale.gen before running locale-gen. I would also suggest to reboot your computer as well after these changes.

I'm not too familiar with locale settings myself, but I'm quite sure the internet has plenty of information for you to look up.

@joelim-work
Copy link
Collaborator

UPDATE: I'm pretty sure this is a locale issue, I was able to reproduce all this on my own computer by running lf using the default locale:

LC_ALL=C lf

This StackExchange answer is a pretty good read, and once you configure your locale settings properly, running locale should result in something similar to the given example in there.

@gokcehan
Copy link
Owner

@joelim-work Thanks for the help. I have now added some of these instructions as a "troubleshoot" to the new colors and icons wiki page. Feel free to change them accordingly. I don't expect any more replies to this issue so I'm closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants