Skip to content

[MacOS]Can not preview any images (png,jpg,jpeg,webp, ...) in iTerm2 #2040

@zhangyonglei

Description

@zhangyonglei

Can not preview any images (png,jpg,jpeg,webp, ...) in iTerm2.

  • MacOS 15.5
  • imgcat/viu all are installed
  • ~/.config/lf/lfrc file settings:
set ratios 1:2:3
set sixel true
set icons true

set previewer /Users/tianyu/.config/lf/preview.sh
set cleaner /Users/tianyu/.config/lf/cleaner.sh
set preview
  • /Users/tianyu/.config/lf/preview.sh file content:
#!/bin/bash
case "$1" in
    *.jpg|*.jpeg|*.png|*.gif|*.bmp|*.webp)
        # tput init
        # tput cup "$4" "$5"
        # tput smcup
        # chafa  -f sixel  --size="$2x$3" -c 256 "$1" 2>>/tmp/lf_error.log
        # viu -w "$2" -h "$3" -x "$4" -y "$5" "$1" 2>>/tmp/lf_error.log
        viu -w "$2" -h "$3" "$1"
        # /Users/tianyu/.iterm2/imgcat --width "$2" --height "$3" "$1"
        # /Users/tianyu/.iterm2/imgcat -r -l --width "$2" --height "$3" "$1"
        # qlmanage -p "$1" > /dev/null 2>&1
        # tput rmcup
        ;;
    *)
        # 其他文件类型的默认预览
        bat --color=always --style=numbers --line-range=:500 "$1" 2>/dev/null || cat "$1"
        ;;
esac
exit 0

Tried all methods with viu and imgcat commands.

BTW, Running the two commands alone work well/correctly in iTerm2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions