regex

Check out your GitHub pull request with an interactive shell menu

When I want to check out a GitHub pull request of my colleagues on my local machine, I usually have to open my browser, go to the pull request page on GitHub, copy the branch name, do a git fetch in my terminal, followed by a git checkout, pasting the branch name. Annoyed by this context switch between terminal and browser and all that mouse movement, I devised a way to select the pull request from a list in the terminal, with a checkout when I hit Enter:

Using grep on files with no newlines

I had a big, automatically-generated HTML file without newlines and wanted to see all occurrences of a certain image name. Using the command grep my_image.png just outputs the whole file - not useful! While writing the question to the unix section of StackExchange, I found a way to do it with grep: grep -oE ".{30}my_image.{30}" This command yielded the desired result: Each occurrence on a separate line, with 30 characters before and after.