aboutsummaryrefslogtreecommitdiff
path: root/functions/utilities.zsh
diff options
context:
space:
mode:
authorBenoit Averty <benoit.averty@gmail.com>2016-08-10 01:07:04 +0300
committerDominik Ritter <dritter03@googlemail.com>2017-02-01 01:47:49 +0300
commitebf808c533ed86ede4b5afcf9206c05b832278db (patch)
tree9a74b5cdb088183077229a7941a796d06118c718 /functions/utilities.zsh
parenta58e8bdc8cf4c51c80dc9e63eef52e95214c54f2 (diff)
Add dir_truncate_root option
Diffstat (limited to 'functions/utilities.zsh')
-rw-r--r--functions/utilities.zsh15
1 files changed, 15 insertions, 0 deletions
diff --git a/functions/utilities.zsh b/functions/utilities.zsh
index f27c7f99..8263ce10 100644
--- a/functions/utilities.zsh
+++ b/functions/utilities.zsh
@@ -208,3 +208,18 @@ function truncatePathFromRight() {
echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \
"s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g"
}
+
+# Search recursively in parent folders for given file.
+function upsearch () {
+ if test -e "$1"; then
+ echo "$PWD"
+ else
+ if [[ "$PWD" == "/" || "$PWD" == "$HOME" ]]; then
+ echo "$PWD";
+ else
+ pushd .. > /dev/null
+ upsearch "$1"
+ popd > /dev/null
+ fi
+ fi
+}