From f5f62c6ba0f438349c11e7e2ab66139e970672c1 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 9 Oct 2017 11:09:05 +0200 Subject: [PATCH] Added cdg function --- zsh/functions.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 43a0754..2d1bd7f 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -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