lotabout / skim

Fuzzy Finder in rust!
MIT License
5.08k stars 180 forks source link

sk as library doesn't have a --ansi option #476

Open DanielKag opened 2 years ago

DanielKag commented 2 years ago

For example, if I try to run git log --online, I'm getting the ANSI characters instead of the color. In the preview, it works well and I can see the colors.

code example:

extern crate skim;
use skim::prelude::*;

pub fn main() {
    let glogm = Some("git log --oneline");

    let options = SkimOptionsBuilder::default()
        .height(Some("50%"))
        .cmd(glogm)
        .preview(Some("echo {}"))
        .multi(true)
        .reverse(true)
        .build()
        .unwrap();

    let selected_items = Skim::run_with(&options, None)
        .map(|out| out.selected_items)
        .unwrap_or_else(|| Vec::new());

    for item in selected_items.iter() {
        print!("selected: {}{}", item.output(), "\n");
    }
}
image
kimono-koans commented 1 year ago

I think you enable via SkimItemReaderOption with the ansi function.