Skip to content

Instantly share code, notes, and snippets.

@tj

tj/some.sh

Created Oct 11, 2012
Embed
What would you like to do?
change terminal tab name on cd
function tabname {
printf "\e]1;$1\a"
}
if [ x`type -t cd` == "xfunction" ]; then
# previously wrapped cd
eval $(type cd | grep -v 'cd is a function' | sed 's/^cd/original_cd/' | sed 's/^}/;}/' )
else
# builtin
eval "original_cd() { builtin cd \$*; }"
fi
cd() {
original_cd "$*"
tabname $(basename $(pwd))
}
@tj

This comment has been minimized.

Copy link
Owner Author

@tj tj commented Oct 11, 2012

@tj

This comment has been minimized.

Copy link
Owner Author

@tj tj commented Oct 11, 2012

@graouts

This comment has been minimized.

Copy link

@graouts graouts commented Feb 27, 2014

I think this script fails with directory names with spaces in them.

~ > cd "Studio Luco" 
-bash: cd: Studio: No such file or directory

My shell scripting skills are too weak to suggest a fix though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment