Skip to content

Instantly share code, notes, and snippets.

@gcamp806
Last active May 9, 2018 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcamp806/6c732d2767e9a7a822ed13a503b280aa to your computer and use it in GitHub Desktop.
Save gcamp806/6c732d2767e9a7a822ed13a503b280aa to your computer and use it in GitHub Desktop.
My custom bashrc script
#!/bin/bash
# Greg's custom bash stuff
# Executed by ~/.bashrc, e.g. source ~/.bash_gcamp
###export EDITOR='sublime'
# prompt helper functions
function parse_git_dirty
{
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
#[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "✘ " || echo "✔ "
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "✘ " || echo "✔ "
fi
}
function git_push_indicator
{
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
[[ $(git log --branches --not --remotes --oneline | nl) ]] && echo -n "↑ "
fi
}
function parse_git_branch
{
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
echo -n ""
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
fi
}
function is_git
{
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
echo -n ":"
fi
}
##function cfind
##{
## grep -inIEr --color=ALWAYS --include="*.c" --include="*.h*" --include="*.cpp" --include="*.hpp" "$1" .
##}
##function pfind
##{
## grep -inIEr --color=ALWAYS --include="*.py" "$1" .
##}
# custom prompt
#PS1='\[\033[01;33m\]\t\[\033[00m\]:\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]$(is_git)\[\033[01;35m\]$(parse_git_branch)\[\033[01;31m\]$(parse_git_dirty)$(git_push_indicator)\[\033[00;31m\]\[\033[00m\] ► '
PS1='\[\e]0;\u@\h: \w\a\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]$(is_git)\[\033[01;35m\]$(parse_git_branch)\[\033[01;31m\]$(parse_git_dirty)$(git_push_indicator)\[\033[00;31m\]\[\033[00m\] ► '
# more ls aliases
###alias ll='ls -alFh'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias em='emacs -nw'
# Shell functions
function cd()
{
if [ -z "$*" ]; then
builtin cd && ls
else
builtin cd "$*" && ls
fi
}
# Machine specific exports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment