Added cdg function

This commit is contained in:
Thomas Forgione 2017-10-09 11:09:05 +02:00
parent b244c70ab2
commit f5f62c6ba0
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
1 changed files with 28 additions and 0 deletions

View File

@ -83,6 +83,34 @@ makelatex() {
cp /home/thomas/.script/classgen/Makefile.latex ./Makefile
}
# cdg : cd to a git repo
if [ -d "$GCLONE_PATH" ]; then
cdg() {
if [ $# -ne 1 ]; then
echo "This function expects a single parameter"
return 1
else
dir=`find $GCLONE_PATH -maxdepth 3 -name $1`
if [[ "" == "$dir" ]]; then
echo "$1 not found"
return 2
elif [ `echo $dir | wc -l` -gt 2 ]; then
echo "Multiple entries for $1 found"
return 3
else
cd $dir
fi
fi
}
_cdg() {
_arguments "1: :($(find $GCLONE_PATH -maxdepth 3 -exec basename {} \;))"
}
compdef _cdg cdg
fi
# Music things
# command -v music-server > /dev/null 2>&1
# if [ $? -eq 0 ]; then