81 points · by spyc · 6y ago · 36 comments
That's worked really well for me
# Remove all local branches for which there is no remote
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -DThe merged branches part is missing.
# diff -u <(echo $'one\ntwo') <(echo one)
--- /dev/fd/63 2020-08-13 16:14:44.449379498 +0200
+++ /dev/fd/62 2020-08-13 16:14:44.450379506 +0200
@@ -1,2 +1 @@
one
-two> Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of <(list) or >(list). The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list.
$ pip install git-delete-merged-branches
zsh: command not found: pip
$ brew install pip
Error: No available formula with the name "pip"
pip is part of the python formula:
brew install python
$ brew install python
...
OK
$ pip install git-delete-merged-branches
zsh: command not found: pip
(look up how to install pip)
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py
WARNING: The scripts pip, pip2 and pip2.7 are installed in
'/Users/{me}/Library/Python/2.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.2
$ pip install git-delete-merged-branches
zsh: command not found: pip
(walk away)
I know there are solutions to all this, and it's mainly that I don't already have my $PATH set up the way that pip expects, etc, but really??At most you’ll have trouble running the right version (rare nowadays, unlike in pre-v1 days)
Homebrew used to unilaterally take over /usr/local, and do all sorts of unconventional things. A few years ago it started playing nicer, but at its core, it's eschewing time-honored conventions across the board.
One of the biggest things about Homebrew that is annoying is that it tries to reuse the stock MacOS libraries to avoid installing dependencies. So you end up with things built against ancient broken regex libs, etc.
MacPorts takes longer to install because it does things right. After you install all the MacPorts GNU libraries and utilities, you have a real Unix system that closely resembles Linux, which is what all the development tools expect.
Linux won the Unix war decades ago, whether anyone likes it or not. MacOS's BSD heritage is still causing pain for people today, especially since the core libraries are literally a decade out of date.
Install-time warning message:
https://github.com/Homebrew/homebrew-core/blob/087008a4c8cfb...
Documentation referenced in the message:
https://docs.brew.sh/Homebrew-and-Python
--
Though not mandatory, you'd also want to add the following to your shell config so that you can have things you install with "pip --user" ready in $PATH:
PATH+="$(/usr/local/opt/libexec/bin/python -c 'import site; print(site.getuserbase())')/bin"
This advice would also apply for Linux, but it's even more important for macOS/Homebrew because otherwise you'd end up messing up /usr/local.