Skip to content

Instantly share code, notes, and snippets.

@wx13
Created January 11, 2013 19:03
Show Gist options
  • Save wx13/4513076 to your computer and use it in GitHub Desktop.
Save wx13/4513076 to your computer and use it in GitHub Desktop.
Current directory in window title; sup'd up 'cd' command.
# Put the CWD in the window title.
function chtt {
echo -en "\033]2;$@\007"
}
export PROMPT_COMMAND='chtt $(pwd)'
# Put the CWD in the window title.
function chtt {
echo -en "\033]2;$@\007"
}
export PROMPT_COMMAND='chtt $(pwd)'
#
# Sup'd up cd command.
#
# ZSH style replacement
function cdx()
{
if [[ "$#" == 2 ]]
then
cwd="$(pwd)"
nwd="${cwd%${1}*}${2}${cwd##*${1}}"
echo "${nwd}"
cd_save_hist "${nwd}"
else
cd_save_hist $@
fi
}
# Expand path for command history.
function cd_save_hist() {
if [ -z "$1" ]
then
d="$HOME"
else
d="$1"
fi
builtin cd "$d"
dp=$(pwd)
history -s cd ${dp}
}
alias cd=cdx
alias cd0='builtin cd'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment