Last active
August 29, 2015 13:57
-
-
Save carmat/9476158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Set title on each tab | |
## ==================================== | |
## Gets the repository directory | |
## name and current branch name | |
## | |
## If the current directory is not a | |
## git repo, a tabname can be specified | |
## ==================================== | |
## @usage: tabname (git) | |
## @usage: tabname name (non-git) | |
function tabname { | |
if [ "$1" ]; then | |
printf "\e]1;$1\a" | |
elif [ -d .git ]; then | |
repo=$(basename `git rev-parse --show-toplevel`) | |
branch="$(git symbolic-ref --short -q HEAD)" || | |
branch="(unnamed branch)" # detached HEAD | |
printf "\e]1;("$repo") "$branch"\a" | |
else | |
printf "\e]1;$1\a" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment