Last active
September 5, 2018 20:09
-
-
Save automagicaly/1298a845759432bf84a8718993bdfb59 to your computer and use it in GitHub Desktop.
git branch on command line
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
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
############################################# | |
# Functions | |
############################################# | |
get_git_branch(){ | |
# Based on: http://stackoverflow.com/a/13003854/170413 | |
local branch | |
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
if [[ "$branch" == "HEAD" ]]; then | |
branc='detached* ' | |
fi | |
symbol=$'\ue725' | |
#git_branch="($symbol $branch) " | |
git_branch="($branch) " | |
else | |
git_branch="" | |
fi | |
} | |
############################################# | |
# Configs | |
############################################# | |
# swap cap and esc | |
setxkbmap -option "caps:swapescape" | |
############################################# | |
# Exports | |
############################################# | |
PROMPT_COMMAND="get_git_branch; $PROMPT_COMMAND" | |
export PS1="\W \[\e[33m\]\$git_branch\[\e[32m\]➤\[\e[0m\] " | |
PATH=$HOME/.local/bin:$PATH | |
export PATH | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment