cleanup bootstrap.sh. reorganize gitconfig.

This commit is contained in:
Ivan Malison 2014-04-14 20:24:52 -07:00
parent bfed868acd
commit 94c3a79793
6 changed files with 44 additions and 46 deletions

View File

@ -1,12 +1,7 @@
#!/bin/sh #!/usr/bin/env bash
case `uname` in cd $BASH_SOURCE && source dotfiles/lib/shellrc/aliases.sh && source dotfiles/lib/bash/aliases.sh
'Darwin') DOTFILES_DIRECTORY="(sourcefile_abspath)/dotfiles"
readlink_command='greadlink' echo $DOTFILES_DIRECTORY
;;
*)
readlink_command='readlink'
esac
DOTFILES_DIRECTORY="$(dirname "${BASH_SOURCE}" | xargs ${readlink_command} -f)/dotfiles"
function symlink_dotfiles() { function symlink_dotfiles() {
cd $DOTFILES_DIRECTORY cd $DOTFILES_DIRECTORY
@ -25,15 +20,24 @@ function symlink_dotfiles() {
[ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups [ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups
} }
if [ "$1" = "--force" -o "$1" = "-f" ]; then
symlink_dotfiles function parse_options() {
else while getopts "f" OPTCHAR; do
case $optchar in
f)
symlink_dotfiles
return
;;
esac
done
shift $((OPTIND-1))
read -p "Symlinking files from $DOTFILES_DIRECTORY. This may overwrite existing files in your home directory. Do you wish to proceed? (y/n) " -n 1 read -p "Symlinking files from $DOTFILES_DIRECTORY. This may overwrite existing files in your home directory. Do you wish to proceed? (y/n) " -n 1
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
symlink_dotfiles symlink_dotfiles
fi fi
fi
}
unset symlink_dotfiles parse_options()
unset DOTFILES_DIRECTORY

View File

@ -1,34 +1,36 @@
[alias] [alias]
# View the SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph l = log --pretty=oneline -n 20 --graph
# View the current working tree status using the short format
s = status -s s = status -s
# Clone a repository including all submodules
c = clone --recursive c = clone --recursive
ff = merge --ff-only ff = merge --ff-only
ca = !git add -A && git commit -av
cam = commit -am
suir = submodule update --init --recursive
poh = push origin HEAD
pohm = push origin HEAD:master
amend = commit -a --amend -C HEAD
dirty = "!t() { test -n \"$(git status --porcelain)\"; }; t"
branches = branch -a
remotes = remote -v
which-branch = "!wb() { b="$(git symbolic-ref HEAD)" && echo ${b#refs/heads/}; }; wb"
sha = rev-parse HEAD
branch-or-sha = "!bs() { git which-branch 2> /dev/null || git sha 2> /dev/null ; }; bs"
# In newer versions of git, this simpler definition of which-branch would work.
# symbolic-ref HEAD --short
ffr = "!ffr() { git fetch $1 && git ff origin/$(git which-branch) && git suir; }; ffr" ffr = "!ffr() { git fetch $1 && git ff origin/$(git which-branch) && git suir; }; ffr"
ffo = !git ffr origin ffo = !git ffr origin
cam = commit -am reset-origin = "!r() { git reset --hard origin/\"$(git which-branch)\" && git suir; }; r"
# Commit all changes
ca = !git add -A && git commit -av
branches = branch -a
remotes = remote -v
# Credit an author on the latest commit # Credit an author on the latest commit
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f" credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
# Interactive rebase with the given number of latest commits # Interactive rebase with the given number of latest commits
reb = "!r() { git rebase -i HEAD~$1; }; r" reb = "!r() { git rebase -i HEAD~$1; }; r"
suir = submodule update --init --recursive
poh = push origin HEAD
pohm = push origin HEAD:master
# Diff a file or show it in git's pager if it is untracked # Diff a file or show it in git's pager if it is untracked
du = "!d() { git ls-files $1 --error-unmatch 2>/dev/null 1>/dev/null && git diff $1 || `git config --get core.pager` $1; }; d" du = "!d() { git ls-files $1 --error-unmatch 2>/dev/null 1>/dev/null && git diff $1 || `git config --get core.pager` $1; }; d"
which-branch = "!wb() { b="$(git symbolic-ref HEAD)" && echo ${b#refs/heads/}; }; wb" # symbolic-ref HEAD --short
sha = rev-parse HEAD
branch-or-sha = "!bs() { git which-branch 2> /dev/null || git sha 2> /dev/null ; }; bs"
amend = commit -a --amend -C HEAD
reset-origin = "!r() { git reset --hard origin/\"$(git which-branch)\" && git suir; }; r"
[core] [core]
# Use custom `.gitignore` and `.gitattributes` # Use custom `.gitignore` and `.gitattributes`
excludesfile = ~/.gitignore excludesfile = ~/.gitignore

View File

@ -0,0 +1 @@
alias sourcefile_abspath='$(readlink -f "$BASH_SOURCE" | xargs dirname)'

View File

@ -6,6 +6,7 @@ alias go2dotfiles='cd $(dirname `readlink -f ~/.zshrc | xargs dirname`)'
# enables the sudoing of aliases. # enables the sudoing of aliases.
alias sudo='sudo ' alias sudo='sudo '
alias get_absolute_directory=
# Detect which `ls` flavor is in use # Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls` if ls --color > /dev/null 2>&1; then # GNU `ls`

View File

@ -1,15 +1,5 @@
function parse_git_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
function git_is_dirty() {
! test -z "$(git status --porcelain)"
}
function current_shell() { function current_shell() {
greadlink -f $(which "$(ps -p $$ | tail -1 | awk '{print $NF}' | sed 's/\-//')") readlink -f $(which "$(ps -p $$ | tail -1 | awk '{print $NF}' | sed 's/\-//')")
} }
function is_zsh() { function is_zsh() {

View File

@ -13,7 +13,7 @@ function git_prompt_info() {
} }
function git_status_character() { function git_status_character() {
if git_is_dirty; if git dirty;
then then
echo "%{$FG[202]%}✘%{$reset_color%}" echo "%{$FG[202]%}✘%{$reset_color%}"
else else
@ -29,7 +29,7 @@ function sandbox_prompt() {
} }
PROMPT='╭─% %{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(hostname -s)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}$(current_directory)%{$reset_color%}$(git_prompt_info)$(sandbox_prompt) PROMPT='╭─% %{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(hostname -s)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}$(current_directory)%{$reset_color%}$(git_prompt_info)$(sandbox_prompt)
$FG[255]╰─± ' $FG[255]%{$reset_color%}╰─± '
PS2='' PS2=''