-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
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 | ||
|
||
|
||
|
||
|
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.
Sorry, something went wrong. |
||
# 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} \[\>>\] " |
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 |
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.
Sorry, something went wrong.
hurtstotouchfire
Author
Owner
|
||
br = branch | ||
co = checkout | ||
nb = checkout -b | ||
fpush = push origin -u HEAD | ||
This comment has been minimized.
Sorry, something went wrong.
hurtstotouchfire
Author
Owner
|
||
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.
Sorry, something went wrong.
hurtstotouchfire
Author
Owner
|
||
sub = submodule update | ||
unstage = reset HEAD | ||
uncommit = reset --soft HEAD~1 | ||
This comment has been minimized.
Sorry, something went wrong.
hurtstotouchfire
Author
Owner
|
||
[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.
Sorry, something went wrong.
hurtstotouchfire
Author
Owner
|
||
[diff] | ||
mnemonicprefix = true | ||
[merge] | ||
stat = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
\#*# | ||
\#* | ||
\.#* | ||
*~ |
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.