Skip to content

Commit

Permalink
adding files
Browse files Browse the repository at this point in the history
  • Loading branch information
hurtstotouchfire committed Jan 19, 2014
1 parent e60c547 commit 64d3259
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 0 deletions.
9 changes: 9 additions & 0 deletions append_to_bashrc
Original file line number Diff line number Diff line change
@@ -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




71 changes: 71 additions & 0 deletions bash_prompt.sh
Original file line number Diff line number Diff line change
@@ -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

This comment has been minimized.

Copy link
@hurtstotouchfire

hurtstotouchfire Jan 19, 2014

Author Owner

Bash prompt coloring is a dark art, and there's actually still a bug in here somewhere. Points to whoever fixes it first. I have been working with this for some time though and it's been fine.

# 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} \[\>>\] "
43 changes: 43 additions & 0 deletions git_setup.sh
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[color]
diff = auto
status = auto
branch = auto

[color "diff"]
meta = yellow

[alias]
st = status
cm = commit -m
cam = commit -am

This comment has been minimized.

Copy link
@hurtstotouchfire

hurtstotouchfire Jan 19, 2014

Author Owner

commit -m will only commit staged changes. commit -am will add all tracked files to the commit. In both cases, the -m lets you provide the commit message as an argument.

br = branch
co = checkout
nb = checkout -b
fpush = push origin -u HEAD

This comment has been minimized.

Copy link
@hurtstotouchfire

hurtstotouchfire Jan 19, 2014

Author Owner

These commands will always be sufficient to make local branches and push them to the origin with the same name. To learn more about branching, see: Branching

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

This comment has been minimized.

Copy link
@hurtstotouchfire

hurtstotouchfire Jan 19, 2014

Author Owner

This git lg command just makes the git log more condensed and has some tree-tracking visualization. I can't live without it and hate the normal git log.

sub = submodule update
unstage = reset HEAD
uncommit = reset --soft HEAD~1

This comment has been minimized.

Copy link
@hurtstotouchfire

hurtstotouchfire Jan 19, 2014

Author Owner

If you commit everything you've changed every time, you can just use the git cam alias and never worry about staging. If you use staging, it can be nice to use the unstage alias. It will also take a filename as an argument.

The uncommit alias is really intended for if you haven't already pushed. If you are working all alone in your branch and you won't harm anyone else, you can uncommit pushed changes and then force push them.

[branch]
autosetupmerge = true
autosetuprebase = always
[core]
whitespace = trailing-space,space-before-tab
filemode = false
autocrlf = input
editor = emacs
[rerere]
enabled = 1
[push]
default = tracking

This comment has been minimized.

Copy link
@hurtstotouchfire

hurtstotouchfire Jan 19, 2014

Author Owner

Branching and tracking can get pretty ugly in git if you don't know what you're doing. Enabling tracking by default and autosetupmerge / autosetuprebase has helped me to keep things simple. There are a lot of options though. To learn more about tracking branches and options for branching, see http://gitready.com/beginner/2009/03/09/remote-tracking-branches.html

[diff]
mnemonicprefix = true
[merge]
stat = true

4 changes: 4 additions & 0 deletions gitignore_global
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\#*#
\#*
\.#*
*~

0 comments on commit 64d3259

Please sign in to comment.