diff --git a/append_to_bashrc b/append_to_bashrc new file mode 100644 index 0000000..d43e3c6 --- /dev/null +++ b/append_to_bashrc @@ -0,0 +1,9 @@ + +# change this to the git repo path here where the dotfiles live. +dot_dir=~/src/dot +# this will just run that file in the repo every time you open a new terminal +. ${dot_dir}/bash_prompt.sh + + + + diff --git a/bash_prompt.sh b/bash_prompt.sh new file mode 100755 index 0000000..b61e7ab --- /dev/null +++ b/bash_prompt.sh @@ -0,0 +1,71 @@ +# Configure bash prompt +# Regular Colors +Black='\e[0;30m\]' # Black +Red='\[\e[0;31m\]' # Red +Green='\[\e[0;32m\]' # Green +Yellow='\[\e[0;33m\]' # Yellow +Blue='\[\e[0;34m\]' # Blue +Purple='\[\e[0;35m\]' # Purple +Cyan='\[\e[0;36m\]' # Cyan +White='\[\e[0;37m\]' # White +Light_Gray="\[\033[0;37m\]" + +# Bold +BBlack='\[\e[1;30m\]' # Black +BRed='\[\e[1;31m\]' # Red +BGreen='\[\e[1;32m\]' # Green +BYellow='\[\e[1;33m\]' # Yellow +BBlue='\[\e[1;34m\]' # Blue +BPurple='\[\e[1;35m\]' # Purple +BCyan='\[\e[1;36m\]' # Cyan +BWhite='\[\e[1;37m\]' # White +BLight_Gray='\[\033[1;37m\]' + +# High Intensity +IBlack='\[\e[0;90m\]' # Black +IRed='\[\e[0;91m\]' # Red +IGreen='\[\e[0;92m\]' # Green +IYellow='\[\e[0;93m\]' # Yellow +IBlue='\[\e[0;94m\]' # Blue +IPurple='\[\e[0;95m\]' # Purple +ICyan='\[\e[0;96m\]' # Cyan +IWhite='\[\e[0;97m\]' # White + +# Bold High Intensity +BIBlack='\[\e[1;90m\]' # Black +BIRed='\[\e[1;91m\]' # Red +BIGreen='\[\e[1;92m\]' # Green +BIYellow='\[\e[1;93m\]' # Yellow +BIBlue='\[\e[1;94m\]' # Blue +BIPurple='\[\e[1;95m\]' # Purple +BICyan='\[\e[1;96m\]' # Cyan +BIWhite='\[\e[1;97m\]' # White + +# reset colors +NONE="\[\e[0m\]" + +# set up git prompt components +function parse_git_branch { + git branch 2>/dev/null | grep '^*' | colrm 1 2 | sed 's_\(.*\)_(\1)_' +} + +function git_dirty { + git diff --quiet HEAD &>/dev/null + [ $? == 1 ] && echo "!" +} +# prompt components, set colors here using names from above. +# Some alternate colors are commented out as examples. +ps1_user="$BIBlue\u$NONE" +#ps1_user="$Blue\u$NONE" # non-intense, non bold blue username +ps1_host="$IGreen\h$NONE" +ps1_dir="$BIYellow\w$NONE" +#ps1_dir="$BICyan\w$NONE" # cyan for dir name, still bold and intense +ps1_git="$Yellow\$(parse_git_branch)$Red\$(git_dirty)$NONE" +#ps1_git="$Cyan\$(parse_git_branch)$Red\$(git_dirty)$NONE" # cyan branch name + +# actually construct prompt +# delimiters between prompt components (like :@) are your default terminal text color, i.e. white +# renders as: user@host:dir(branch)! $ +export PS1="${ps1_user}@${ps1_host}:${ps1_dir}${ps1_git} \[\$\] " +# renders as: dir(branch)! >> +#export PS1="${ps1_dir}${ps1_git} \[\>>\] " \ No newline at end of file diff --git a/git_setup.sh b/git_setup.sh new file mode 100755 index 0000000..a844693 --- /dev/null +++ b/git_setup.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# check git repo path argument +dot_dir=$1 +if [ -z "${dot_dir}" ]; then + echo "No argument supplied. Try from the directory: sh git_setup.sh \`pwd\`" +elif [ ! -d "${dot_dir}" ]; then + echo "Argument is not a directory. Try from the directory: sh git_setup.sh \`pwd\`" +else + # if everything looks ok... + # softlink gitconfig into home directory, will not overwrite files + file="gitconfig" + backup="${HOME}/.gitconfig_old" + # check if the file is already symlinked + if [ -h "${HOME}/.${file}" ]; then + echo "${HOME}/.${file} is already symlinked:" + ls -al ${HOME}/.${file} + # check if the file exists and move before linking + elif [ -f "${HOME}/.${file}" ]; then + mv ${HOME}/.${file} ${backup} + echo "${HOME}/.${file} already exists. It has been moved to ${backup}" + ln -s $dot_dir/$file ${HOME}/.$file 2> /dev/null + echo "File link created:" + ls -al ${HOME}/.${file} + # otherwise, symlink it + else + ln -s $dot_dir/$file ${HOME}/.$file 2> /dev/null + echo "File link created:" + ls -al ${HOME}/.${file} + fi + # set gitignore global to the versioned file in the dotfiles directory + git config --global core.excludesfile ${dot_dir}/gitignore_global + + # get user's name and email + echo "Enter a name to appear on your git commits: " + read name + echo "Enter an email address for your git commits: " + read email + + # add name and email to git config + git config --global user.name "${name}" + git config --global user.email "${email}" +fi diff --git a/gitconfig b/gitconfig new file mode 100644 index 0000000..d78b027 --- /dev/null +++ b/gitconfig @@ -0,0 +1,38 @@ +[color] + diff = auto + status = auto + branch = auto + +[color "diff"] + meta = yellow + +[alias] + st = status + cm = commit -m + cam = commit -am + br = branch + co = checkout + nb = checkout -b + fpush = push origin -u HEAD + df = diff --word-diff=color + lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr - %cn)%Creset' --abbrev-commit --date=relative + sub = submodule update + unstage = reset HEAD + uncommit = reset --soft HEAD~1 +[branch] + autosetupmerge = true + autosetuprebase = always +[core] + whitespace = trailing-space,space-before-tab + filemode = false + autocrlf = input + editor = emacs +[rerere] + enabled = 1 +[push] + default = tracking +[diff] + mnemonicprefix = true +[merge] + stat = true + diff --git a/gitignore_global b/gitignore_global new file mode 100644 index 0000000..dccc2ce --- /dev/null +++ b/gitignore_global @@ -0,0 +1,4 @@ +\#*# +\#* +\.#* +*~