From 14df797f62a3e146f5ba0c879d9f689e7216f958 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Tue, 14 Aug 2012 13:02:19 +0200 Subject: [PATCH] superficial changes --- bash/prompt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bash/prompt b/bash/prompt index 5528c71..fba8bf2 100644 --- a/bash/prompt +++ b/bash/prompt @@ -1,3 +1,9 @@ + +# truncates a string on the left +# $1: string to truncate +# $2: maximum length +# $3: truncation string replacement (optional) +# $4: separator symbol (optional, prevents truncation of rightmost item) __truncate_left() { local str="$1" local maxlen="$2" @@ -23,14 +29,16 @@ __truncate_left() { echo "$str" } -__truncate_dir() { +# truncates a path +__truncate_path() { #gain some place with '~' - dir=${1/#$HOME/\~} - __truncate_left "$dir" 25 '…' '/' + local path=${1/#$HOME/\~} + __truncate_left "$path" 25 '…' '/' } +# truncates CWD __tpwd() { - __truncate_dir "$PWD" + __truncate_path "$PWD" } #__print_rprompt() {