#
# Toggle between directory structures with similar hierarchies.
#
# The root of each directory structure must contain a symbolic link '.at'
# pointing to the root of the other directory.
#
# IMPORTANT: Both symbolic links must be absolute (/udd/bob/foo but not ../foo)
#
# Example:
#
# Consider two directories /udd/bob/work and /udd/scratch/work with identical
# structured (as created by a typical 'configure' script)
#
# cd /udd/bob/work ; ln -s /udd/scratch/work .at
# cd /udd/scratch/work ; ln -s /udd/bob/work .at
#
# Then you can do things like that:
#
# cd /udd/bob/work/src/lib
# edit myfile.c
# @ -> equivalent to 'cd /udd/scratch/work/src/lib'
# make
# @ -> equivalent to 'cd in /udd/bob/work/src/lib'
# edit myfile.c
#
#
function @ () {
local DIR HERE DEST
DIR=$PWD
HERE="$PWD/"
DEST=
while [[ "$DIR" != "/" ]] ; do
if [ -L $DIR/.at -a -d $DIR/.at ] ; then
DIR2=$(readlink -n $DIR/.at)
cd ${HERE/#$DIR/$DIR2}
return
fi
DIR=$(dirname $DIR) ;
done
echo "*** unmanaged directory (symlink '.at' not found) ***"
}
[^] # Re: déplacement rapide entre build et sources
Posté par SChauveau . En réponse au journal Des bookmarks dans mon terminal !. Évalué à 1.
Pour ceux intéressés