summaryrefslogtreecommitdiffstats
path: root/zsh
diff options
context:
space:
mode:
authorGravatar Tom Willemse2015-06-17 11:02:14 +0200
committerGravatar Tom Willemse2015-06-17 11:02:14 +0200
commitca31d5917695f07050e3c772f2209b59210a3a2f (patch)
tree746ca7635dd5fb6ea822c314844a1f2dcf49c94b /zsh
parent6d7bd71f131144bdf672281c5bb8aad342e8e427 (diff)
downloaddotfiles-ca31d5917695f07050e3c772f2209b59210a3a2f.tar.gz
dotfiles-ca31d5917695f07050e3c772f2209b59210a3a2f.zip
Add zsh function to go to a project's root dir
Diffstat (limited to 'zsh')
-rw-r--r--zsh/.zsh/functions/cdp13
1 files changed, 13 insertions, 0 deletions
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