From ca31d5917695f07050e3c772f2209b59210a3a2f Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 17 Jun 2015 11:02:14 +0200 Subject: [PATCH] Add zsh function to go to a project's root dir --- zsh/.zsh/functions/cdp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 zsh/.zsh/functions/cdp diff --git a/zsh/.zsh/functions/cdp b/zsh/.zsh/functions/cdp new file mode 100644 index 0000000..0fe9697 --- /dev/null +++ b/zsh/.zsh/functions/cdp @@ -0,0 +1,13 @@ +# -*- mode: sh; -*- +local _pwd=$(pwd) + +while; do + cd .. + [[ ! -d '.git' && "$(pwd)" != "/" ]] || break +done + +if [[ "$(pwd)" == "/" ]]; then + cd $_pwd + echo 'Project root not found' >&2 + return 1 +fi