summaryrefslogtreecommitdiff
path: root/functions/utilities.zsh
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2017-02-14 05:07:10 +0300
committerBen Hilburn <bhilburn@gmail.com>2017-02-14 05:07:10 +0300
commit5957aef79ae2747e54babb7d65f99df88f63ec42 (patch)
treeaf41c384b9ff54428d56bf8bd65ba942d356662c /functions/utilities.zsh
parentfa255ba86816b804a54f52230c265fb21b8c6f21 (diff)
parentae553a7c7f418b0b761c0fd8cf0427adeaedd96a (diff)
Merge branch 'next' into shibumi-next
Diffstat (limited to 'functions/utilities.zsh')
-rw-r--r--functions/utilities.zsh16
1 files changed, 16 insertions, 0 deletions
diff --git a/functions/utilities.zsh b/functions/utilities.zsh
index f27c7f99..22b53c6a 100644
--- a/functions/utilities.zsh
+++ b/functions/utilities.zsh
@@ -208,3 +208,19 @@ 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 [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then
+ echo "$PWD"
+ elif test -e "$1"; then
+ pushd .. > /dev/null
+ upsearch "$1"
+ popd > /dev/null
+ echo "$PWD"
+ else
+ pushd .. > /dev/null
+ upsearch "$1"
+ popd > /dev/null
+ fi
+}