Created
March 14, 2020 00:54
-
-
Save nathan-v/dc57a9beb79b6d5bee7e3ddc1a48b5bc to your computer and use it in GitHub Desktop.
Handy little title setter that makes sure that the title always reflects where you are and what is going on it git in that directory
This file contains 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
# Title setting function | |
function git_title { | |
# See if we're in a git path | |
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) = true ]]; then | |
# Set the title to <git parent folder name>:<current branch> like "mycoollib:master" | |
echo -ne "\033]0;$(basename `git rev-parse --show-toplevel`):$(git rev-parse --abbrev-ref HEAD)\007" | |
else | |
# Set the title to the present working directory | |
echo -ne "\033]0;$PWD\007" | |
fi | |
} | |
PROMPT_COMMAND=git_title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment