Last active
October 13, 2015 16:48
-
-
Save ehlertij/4226405 to your computer and use it in GitHub Desktop.
Set OSX terminal window to git repo name or current 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
# 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 | grep -o -e [\-,\_,a-z,A-Z]*$`\007" | |
else | |
git-term | |
fi | |
} | |
# Use a bash hook rather than aliasing 'cd' | |
export PROMPT_COMMAND="term-tab-name; $PROMPT_COMMAND" |
I'm redoing part of this because for whatever reason Its hating on me. so far I'm at:
git remote -v | grep '(fetch)' | awk '{ print $2 }' | awk -F/ '{print $NF }'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could probably just
awk '{ print $2 }'
on the second, long grep ingit-repo