[Libreoffice] small utility script to handle ../bin/g and similar commands

Norbert Thiebaud nthiebaud at gmail.com
Fri Oct 8 18:58:26 PDT 2010


I found myself weary of typing ./ or ../ or ../../ etc to get to ./bin/g
an immediate solution is to make an alias with the full path
alias g='/home/me/git/oo/build/bin/g'
but that imply that you have only one git clone... and I have 2 (one
to work in, the other one to build pristine git pull while I mess with
the first view

so:
I created find-lo-bin, which I put in a directory in my PATH

#!/bin/bash

current_dir=`pwd`

# go up the chain until you find a .git
while [ ${current_dir} != "/" -a -d "${current_dir}" -a ! -d
"${current_dir}/.git" ] ;
do
    current_dir=$(dirname "${current_dir}")
done

# if you are in a git repo under clone, go 2 more steps up
if [ $(basename $(dirname ${current_dir})) = "clone" ] ; then
    current_dir=$(dirname $(dirname "${current_dir}"))
fi

echo "${current_dir}/bin"
unset current_dir
---------------

and then

I added in my .bashrc

alias g='$(find-lo-bin)/g'

The other thing that I find myself repeatedly doing is to run the same
git command on
the root repo and on all the others via ./bin/g

'ga' is a little script take care of that:

#!/bin/bash

cd $(find-lo-bin)/..
if [ "$1" = "-f" ] ; then
    shift
    git "$@"
    ./bin/g -f "$@"
else
    git "$@" && ./bin/g "$@"
fi
cd -


Norbert


More information about the LibreOffice mailing list