Skip to content

Instantly share code, notes, and snippets.

@chenqj
Created February 27, 2012 15:26
Show Gist options
  • Select an option

  • Save chenqj/1924654 to your computer and use it in GitHub Desktop.

Select an option

Save chenqj/1924654 to your computer and use it in GitHub Desktop.
动态更改iTerm的tab title
##############################
# 在通过cd命令更改目录时,可动态将iTerm的tab title改为当前的目录(只取最近的目录名)
# Usage:加入到~/.bash_profile,并重新source使其生效
##############################
# change tab title
settitle() { printf '\e]0;'${@}'\a' ; return ; }
# rewrite cd
cd() { command cd "$@"; settitle $(basename $(pwd)); return ; }
settitle $(basename $(pwd))
##############################
# 更简单的版本
# Usage:加入到~/.bash_profile,并重新source使其生效
##############################
export PROMPT_COMMAND='echo -ne "\033]0;$(basename $(PWD))\007"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment