On windows, Notepad++ compare plugin let’s you compare unsaved files. So to compare two texts copied from elsewhere, just make two new tabs and paste the texts. Compare plugin will happily compare line by line.

On Linux I havent found something similar. The closes is Kate, but you still have to save tmp1.txt and tmp2.txt , and remove the clutter when finished.

Does anybody know a compare app that just lets you paste two text blocks without saving files first?

  • dihutenosa@piefed.social
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 days ago
    diff <<EOF  
    pastestuffhere  
    EOF  
    

    while this is running, paste the other stuff into terminal. I’m assuming diff reads stdin, if not given a filename.

  • thingsiplay@lemmy.ml
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    3 days ago

    I quickly wrote a script that uses kdialog from KDE to input text in a box, then writes both files to a temporary file, compares with diff and outputs the difference in a text box again. At the end it deletes the temporary files (if they are not deleted, they will be removed automatically with next system boot anyway). It’s a quick and dirty script.

    I call it diffuse, for diff + use.

    #!/usr/bin/env bash
    
    title="Diff - Compare 2 Texts"
    output_size="720x720"
    
    file1="$(mktemp)"
    file2="$(mktemp)"
    file3="$(mktemp)"
    
    kdialog --title "${title} (input)" --textinputbox "Input Text 1" >> "${file1}"
    kdialog --title "${title} (input)" --textinputbox "Input Text 2" >> "${file2}"
    diff -- "${file1}" "${file2}" >> "${file3}"
    kdialog --title "${title} (diff)" --geometry "${output_size}" --textbox "${file3}"
    
    rm -- "${file1}"
    rm -- "${file2}"
    rm -- "${file3}"
    

    Edit: Forgot to mention the name of the script. Edit2: Totally wrong shebang line corrected.

  • Jestzer@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    3 days ago

    It’s not a very Linux-y answer, but VSC does allow you to compare 2 pages for differences. Those pages can be unsaved or saved files.

    • klangcola@reddthat.comOP
      link
      fedilink
      arrow-up
      1
      ·
      2 days ago

      Thanks, I’ll add VSCode/ium to the arsenal. I tend underutilize VSCode since Kate usually does everything needed by a text editor without all the baggage.