Friday, April 23, 2021

Unix line endings in windows under git

git config --global core.autocrlf false
git config --global core.eol lf

Original Stack Overflow answer

Monday, June 8, 2020

git svn

"Cherry pick" all changes required to make same as another branch:

git merge --squash -X theirs <other_branch>

Makes no commit, but stages all changes

Monday, February 3, 2020

Git project branch and directory info

To get the Git top level, or root, of the repo:

git rev-parse --show-toplevel

Get the current current branch name:

git rev-parse --abbrev-ref HEAD

Get the current working directory relative to project root:

echo "${PWD##$(git rev-parse --show-toplevel)}"

Get the current working directory relative to project root and the branch name in one line:

echo "${PWD##$(git rev-parse --show-toplevel)} [$(git rev-parse --abbrev-ref HEAD)]"

Wednesday, August 23, 2017

Getting pulseaudio volume for default sink, once and for all

This was done with pulseaudio 8.0

So, here it is:

echo $(( ($(pacmd list-sinks | sed -n -e "/$(pacmd stat | grep "Default sink name" | cut -d ' ' -f4)/,\$p" | grep -m1 volume | cut -d '/' -f2,4 | tr -d '% ' | tr '/' '+')) / 2 ))

Wow.. that's a mouthful. Let's break it down...

Wednesday, May 17, 2017

Drive images with progress indication

# make a drive image
sudo bash -c "pv -EE /dev/sdX >my_disk.img"

# make a compressed drive image
sudo bash -c "pv -EE /dev/sdX | gzip >my_disk.img.gz"

Monday, June 13, 2016

Resizing a VirtualBox disk image

This should go without saying, but make sure you have a good backup of everything before you do any of this.. If in doubt, just backup the whole VirtualBox folder. You have been warned.

Sunday, May 1, 2016

Configuring Gnome-Shell from the command line

Here's some useful tricks to automate the configuration of the gnome shell