bash_aliases: cd_hook_change_terminal_title: compute $PWD basename instead of shelling out

This commit is contained in:
Josh Holtrop 2014-02-27 12:10:40 -05:00
parent a8360d38e1
commit d405c27c1d

View File

@ -57,7 +57,11 @@ case "$TERM" in
[ax]term*|rxvt*)
function cd_hook_change_terminal_title()
{
echo -ne "\033]0;"$(basename "$PWD")" [${USER}@${HOSTNAME}: ${PWD}]\007"
local dirname=""
if [[ "${PWD}" =~ .*/(.*) ]]; then
dirname="${BASH_REMATCH[1]}"
fi
echo -ne "\033]0;"$dirname" [${USER}@${HOSTNAME}: ${PWD}]\007"
}
;;
*)