Code Snippets

git alias

Here is the alias portion of my ~/.gitconfig mentioned in lecture 3:

[color]
        ui = true
[alias]
        st = status
        ci = commit
        co = checkout
        ls = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
        ll = log --pretty=format:\"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]\" --decorate --numstat
        hist = log --graph --decorate --pretty=oneline --abbrev-commit
        pu = pull --all --prune
## https://dev.to/devcamilla/why-git-alias-575h
## https://dev.to/megamattmiller/the-git-aliases-that-get-me-to-friday-1cmj
        nb = checkout -b
        fp = fetch -p

bashrc

Here is a portion of my ~/.bashrc mentioned in lecture 4 to display git branches:

## Set the prompt to show the current git branch:
function parse_git_branch {
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return
    echo "("${ref#refs/heads/}")"
}
## this works (once parse_git_branch above has been defined) and does not have user@host, just 'host:dir(branch): '
#export PS1='\[\e[38;5;202m\]\[\e[38;5;245m\]\[\e[00m\]\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;202m\]\w\[\e[38;5;245m\]$(parse_git_branch)\[\e[00m\]$ '
## this one has user@host:working/dir(branch):
export PS1='\[\e[38;5;202m\]\u\[\e[38;5;245m\]@\[\e[00m\]\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;202m\]\w\[\e[38;5;245m\]$(parse_git_branch)\[\e[00m\]$ '