diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2017-02-14 04:18:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-14 04:18:44 +0300 |
commit | 221030013e93e6fcde44b8a6c656db9139c142c9 (patch) | |
tree | 39fd2ef32ad7dc45e0868356f1341f5a1269d037 /functions/utilities.zsh | |
parent | 1de14df11fb3bf67958555b921f8323cda0d3d03 (diff) | |
parent | 6e1259ee99a51a8cb52f975ebb45ede2792a4730 (diff) |
Merge pull request #398 from dritter/benoits_dir_segment
Add "truncate_with_folder_marker" shorten strategy
Diffstat (limited to 'functions/utilities.zsh')
-rw-r--r-- | functions/utilities.zsh | 16 |
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 +} |