Skip to content

Instantly share code, notes, and snippets.

@brycesch
Forked from ehlertij/.bash_profile
Last active December 21, 2015 09:29
Show Gist options
  • Save brycesch/6285049 to your computer and use it in GitHub Desktop.
Save brycesch/6285049 to your computer and use it in GitHub Desktop.
# Set terminal window name to current git repo (and branch) or current directory
git-repo() {
git remote -v | grep '(fetch)' | grep -o "\/[a-z,A-Z,\_,\-]*\." | tail -1 | cut -c 2- | grep -o "[a-z,A-Z,\_,\-]*"
}
git-branch() {
git branch | grep \* | cut -c 3-
}
git-term() {
echo -n -e "\033]0;`git-repo`\007"
}
term-tab-name() {
git remote >/dev/null 2>&1
if (($?)); then
echo -n -e "\033]0;`pwd`\007"
else
git-term
fi
}
precmd () {term-tab-name}
@brycesch
Copy link
Author

updated to work with zsh

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