Skip to content

16th Week of 2022

Computer Science

GNULinux

Basics

  • New: Get the cursor position.

    Useful for recording part of the screen with (ffmpeg)[ffmpeg].

    watch -n 0.1 xdotool getmouselocation
    

Git

  • New: Merge conflict style.

    Take the pain out of git conflict resolution: use diff3

    git config --global merge.conflictstyle diff3
    

    After running this command to turn on diff3, each new conflict will have a 3rd section, the merged common ancestor.

    <<<<<<< HEAD
    GreenMessage.send(include_signature: true)
    ||||||| merged common ancestor
    BlueMessage.send(include_signature: true)
    =======
    BlueMessage.send(include_signature: false)
    >>>>>>> merged-branch
    
  • New: View file evolution.

    You can use git log -L to view the evolution of a range of lines. Example:

    git log -L 15,23:filename.txt
    

    means trace the evolution of lines 15 to 23 in the file named filename.txt.

  • New: Compare file accross references.

    To compare a file accross references (branches, tags, commits...) do:

    git diff <reference1> <reference2> -- <file>
    

grep

  • New: Common options.

    • -r: recursively search a directory.
    • -i: ignore case.
    • -l: print only the path of the files that have at least one match.
  • New: Limit results line length.

    First 400 bytes of the line:

    grep "foobar" * | cut -b 1-400
    

    This might leave the match out, but it's simple to use and enough for most cases. The other option is:

    grep -rEo ".{0,10}wantedText.{0,10}" *
    

neovim

  • New: Marks.

    A mark allows you to record your current position so you can return to it later.

    Usage:

    • :marks: show existing marks.
    • ma: set mark a in current position of current file, accessible only from the current file.
    • mA: set mark A in current position of current file, accessible from anywhere.
    • 'a: Go to mark a.
    • ]': jump to next line with a lowercase mark.
  • New: Sed replace with newline.

  • New: Without RegEx.

    Use :sno instead of :s to disable magic.