This commit is contained in:
Jephté Clain 2024-05-12 23:46:40 +04:00
parent 006964df45
commit c8aee44c2a
1 changed files with 7 additions and 4 deletions

View File

@ -248,15 +248,18 @@ function ppath() {
echo "$path" echo "$path"
} }
function ppath2() { function ppath2() {
# Comme ppath() mais afficher '.' comme '../$dirname' # Comme ppath() mais afficher '.' comme '. ($dirname)' pour la joliesse
local path="$1" cwd="$2" local path="$1" cwd="$2"
path="$(abspath "$path")" # essayer de normaliser le chemin path="$(abspath "$path")" # essayer de normaliser le chemin
[ -n "$cwd" ] || cwd="$(pwd)" [ -n "$cwd" ] || cwd="$(pwd)"
[ "$path" == "$cwd" ] && path="../$(basename -- "$path")" if [ "$path" == "$cwd" ]; then
[ "$cwd" != "/" -a "$cwd" != "$HOME" ] && path="${path#$cwd/}" path=". ($(basename -- "$path"))"
[ "${path#$HOME/}" != "$path" ] && path="~${path#$HOME}" else
[ "$cwd" != "/" -a "$cwd" != "$HOME" ] && path="${path#$cwd/}"
[ "${path#$HOME/}" != "$path" ] && path="~${path#$HOME}"
fi
echo "$path" echo "$path"
} }