neovim view who changed expandtab
When pressing newline in a .go file, I got tabs instead of spaces (my default setting). This helped me track where the setting was changed:
:verb set expandtab?
bash overridable variables in scripts
This script will show default when ran without any arguments:
and running it like this:
myvar=different ./script.sh
will show different
git error cannot lock ref
Had this error:
error: cannot lock ref 'refs/remotes/origin/feature/SomeBranch': ref refs/remotes/origin/feature/SomeBranch is at SOME_SHA b ut expected SOME_OTHER_SHA
This fixed it:
rm .git/refs/remotes/origin/feature/SomeBranch
vim compare two files in a split
Setup a split, and then write:
:windo diffthis
To disable diffing:
:windo diffoff
bash process substitution while loop
I recently stumbled upon a problem in a bash script. I was doing something like this:
Basically, when I was echoing, after the while, I was expecting the modified value to be shown. However, piping into something will create a new subshell, and thus the modification is only visible inside that shell. This link gives some useful examples on process substitution. The fix was to rewrite that loop like this:
grep and show only matching part
Here’s how to grep for something and show only the matching part: