diff options
author | Tom Willemse | 2015-06-17 11:02:14 +0200 |
---|---|---|
committer | Tom Willemse | 2015-06-17 11:02:14 +0200 |
commit | ca31d5917695f07050e3c772f2209b59210a3a2f (patch) | |
tree | 746ca7635dd5fb6ea822c314844a1f2dcf49c94b /zsh/.zsh | |
parent | 6d7bd71f131144bdf672281c5bb8aad342e8e427 (diff) | |
download | dotfiles-ca31d5917695f07050e3c772f2209b59210a3a2f.tar.gz dotfiles-ca31d5917695f07050e3c772f2209b59210a3a2f.zip |
Add zsh function to go to a project's root dir
Diffstat (limited to 'zsh/.zsh')
-rw-r--r-- | zsh/.zsh/functions/cdp | 13 |
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 |