The version was/is of little relevance, the discussion is what the code does.
ppwd () {
local dir #local var `dir`
local -i width #local integer variable
test -n "$TS1" || return; #Check if TS1(timestamp?)
dir="$(dirs +0)" #get current path
let width=${#dir}-18 #get diff of dirs.len - 18
test ${#dir} -le 18 || dir="...${dir#$(printf "%.*s" $width "$dir")}" #shorten to `...some/18chars`
if test ${#TS1} -gt 17 ; then #take into account TS width
printf "$TS1" "$USER" "$HOST" "$dir" "$HOST"
else
printf "$TS1" "$USER" "$HOST" "$dir"
fi
}
else
ppwd () { true; }
fi
user@ost:~/Downloads/cudnn-linux-x86_64-8.9.7.29_cuda12-archive$ ~/btest.sh
user ....29_cuda12-archive
henk@boven:~> LANG=C type ppwd
ppwd is a function
ppwd ()
{
local dir;
local -i width;
test -n "$TS1" || return;
dir="$(dirs +0)";
let width=${#dir}-18;
test ${#dir} -le 18 || dir="...${dir#$(printf "%.*s" $width "$dir")}";
if test ${#TS1} -gt 17; then
printf "$TS1" "$USER" "$HOST" "$dir" "$HOST";
else
printf "$TS1" "$USER" "$HOST" "$dir";
fi
}
henk@boven:~>
You can easily see what the code does by removing the invocation of ppwd from your PS1 and comparing the result. Otherwise you probably need to ask more specific question(s) which are likely more in place on Programming subforum.
No, it is not timestamp, it is just shell variable that is defined and set in the earlier code of the script containing definition of this function.