Skip to content

Instantly share code, notes, and snippets.

@fractalf
Last active October 12, 2017 12:03
Show Gist options
  • Save fractalf/9bfaa4cd4398bb977c3918c77cbe0e81 to your computer and use it in GitHub Desktop.
Save fractalf/9bfaa4cd4398bb977c3918c77cbe0e81 to your computer and use it in GitHub Desktop.
Cheatsheet

Fractalf's cheatsheet

Handy stuff

grep

  • grep -B 2 -A 3 foo bar Show 2 lines before and 3 lines after grepping for foo in bar
  • grep --color=always foo bar | less -r show foo in colors also when piping to less
  • grep -E "(foo|bar)" * find files containing foo or bar (Note: file will be displayed twice)

git

  • git diff -w ignore whitespace when comparing line

less

  • options
    • -r show "raw" control characters (colors)
  • commands
    • g goto top
    • G goto bottom
    • /foo search for foo
    • n next search
    • N previous search

bash/sh

  • git grep foo | cut -d : -f 1 | uniq | while read i; do sed -r -i s,foo,bar,g $i; done
    • cut -d delimiter (what char divides the search)
    • cut -f field (what field to get from -d search)
    • uniq filter out duplicates
    • sed -r extended regular expressions
    • sed -i edit files in place

linux

  • firefox scroll wheel speed: about:config
    • mousewheel.acceleration.factor: 40
    • mousewheel.acceleration.start: 0
    • browser.backspace_action: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment