Skip to content

Instantly share code, notes, and snippets.

@aboyon
Created March 19, 2017 06:14
Show Gist options
  • Save aboyon/1bf18f962f9138549eff7f28a2849b88 to your computer and use it in GitHub Desktop.
Save aboyon/1bf18f962f9138549eff7f28a2849b88 to your computer and use it in GitHub Desktop.
# git-related functions in here
git_branch () {
GIT_BRANCH="$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
if [[ -n "$GIT_BRANCH" ]] ; then
echo ":($GIT_BRANCH) "
fi
}
empty_branch () {
name="$1"
if [[ -n "$name" ]] ; then
echo "This will create a new empty branch in the current"
echo -n "git repository called '${name}' ... Continue? [y/N] "
read VERIFY
if [[ "$VERIFY" = "Y" || "$VERIFY" = "y" ]]; then
echo "creating branch '$name'"
git symbolic-ref HEAD refs/heads/$name
rm .git/index
git clean -fdx
echo "you should be on your new empty branch! "
echo "add/commit files as usual! "
echo "( your new branch will show up after you commit something to it )"
else
echo -n ""
fi
else
echo "Creates a new empty branch in your git repository."
echo ""
echo "Usage: empty_branch [name_of_new_branch]"
fi
}
# vim:set ft=sh:
#### para GIT
# if .bash_functions if a file then source it
# if .bash_functions is a directory, then sourec all its files
if [ -f ~/.bash_functions ]; then
. ~/.bash_functions
fi
if [ -d ~/.bash_functions ]; then
for function in ~/.bash_functions/*; do . $function; done
fi
# bash prompt
prompt () {
PS1="\[\e[36m\]\u\[\e[37m\]@\[\e[36m\]\h\[\e[37m\]:\[\e[31m\]\w\[\e[37m\]$(git_branch)$ "
}
PROMPT_COMMAND=prompt
export PROMPT_COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment