Skip to content

Commit

Permalink
Now with Zprezto!
Browse files Browse the repository at this point in the history
- cleaned up erroneous directories
- partitioned out logic based on what was in zprezto already
- just made it a lot cleaner
  • Loading branch information
craveytrain committed Mar 4, 2015
1 parent 5bee4a7 commit 117b891
Show file tree
Hide file tree
Showing 55 changed files with 545 additions and 626 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -22,3 +22,6 @@
[submodule "vim/vim.symlink/bundle/vim-javascript"]
path = vim/vim.symlink/bundle/vim-javascript
url = git://github.com/pangloss/vim-javascript.git
[submodule "zprezto"]
path = zprezto
url = https://github.com/craveytrain/prezto.git
1 change: 0 additions & 1 deletion ack/ack.sh

This file was deleted.

20 changes: 20 additions & 0 deletions bash/aliases.bash
@@ -1,2 +1,22 @@
# Profile reload
alias reload!='. ~/.bashrc'

alias ls="ls -FG" # ls with those helpful little trailing characters
alias ll='ls -lh' # Lists human readable sizes.
alias la='ll -A' # Lists human readable sizes, hidden files.
alias lm='la | "$PAGER"' # Lists human readable sizes, hidden files through pager.
alias lx='ll -XB' # Lists sorted by extension (GNU only).
alias lk='ll -Sr' # Lists sorted by size, largest last.
alias lt='ll -tr' # Lists sorted by date, most recent last.
alias lc='lt -c' # Lists sorted by date, most recent last, shows change time.
alias lu='lt -u' # Lists sorted by date, most recent last, shows access time.

# Make e work for editor
alias e='${VISUAL:-$EDITOR}'

# Colorize grep
alias grep='GREP_COLOR="1;37;45" LANG=C grep --color=auto'

# Resource Usage
alias df='df -kh'
alias du='du -kh'
2 changes: 1 addition & 1 deletion bash/bash_profile.symlink
Expand Up @@ -2,4 +2,4 @@

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
94 changes: 26 additions & 68 deletions bash/bashrc.symlink
Expand Up @@ -6,82 +6,40 @@ export LANG=en_US.UTF-8
# shortcut to this dotfiles path is $DOTFILES
export DOTFILES="$(cd $(dirname $(readlink ~/.bashrc)) && cd .. && pwd)"

# prepend an entry to PATH if it is a dir, and not already in path.
path_unshift() {
if [ -d "$1" ]; then
if [[ ":$PATH:" != *":$1:"* ]]; then
path_remove "$1"
fi
PATH="$1:$PATH"
fi
}
# keeping the paths simple
export PATH=$HOME/bin:$DOTFILES/bin:/usr/local/bin:/usr/local/sbin:/usr/local/opt/coreutils:$PATH

# append an entry to PATH if it is a dir, and not already in path.
path_add() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$PATH:$1"
fi
}
# Don't clear the screen after quitting a manual page
export MANPAGER="less -X"

# remove something from the path
path_remove() {
if [[ ":$PATH:" = *":$1:"* ]]; then
PATH=$(IFS=':';t=($PATH);unset IFS;t=(${t[@]%%*$1*});IFS=':';echo "${t[*]}");
fi
}
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-F -g -i -M -R -S -w -X -z-4'

source_if_present() {
if [ -f "$1" ]; then
. "$1"
fi
if [ -f "$1" ]; then
. "$1"
fi
}

source_files_by_name() {
for source_file in $(find $DOTFILES -name "$1"); do
source_if_present $source_file
done
}

# Source global definitions
source_if_present /etc/bashrc

# set paths
for path_file in $(find $DOTFILES -name "path"); do
if [[ $path_file == */osx/* ]]; then
if [[ $OSTYPE == darwin* ]]; then
source_if_present $path_file
fi
elif [[ $path_file == */linux/* ]]; then
if [[ $OSTYPE == linux* ]]; then
source_if_present $path_file
fi
else
source_if_present $path_file
fi
done
# Makeup for lack of zprezto
source_if_present "$DOTFILES/bash/prompt.bash"
source_if_present "$DOTFILES/bash/aliases.bash"
source_if_present "$DOTFILES/python/virtualenvwraper.sh"
source_if_present "$DOTFILES/ruby/rbenv.sh"

source_if_present ".bash_aliases"
# Load all the shared files
source_if_present "$DOTFILES/system/load.sh"

# source every .bash file in this repo
for bash_file in $(find $DOTFILES -name "*.sh" -o -name "*.bash"); do
if [[ $bash_file == */osx/* ]]; then
if [[ $OSTYPE == darwin* ]]; then
source_if_present $bash_file
fi
elif [[ $bash_file == */linux/* ]]; then
if [[ $OSTYPE == linux* ]]; then
source_if_present $bash_file
fi
else
source_if_present $bash_file
fi
done

# source every completion file in this repo
for completion_file in $(find $DOTFILES -name "bash_completion"); do
if [[ $completion_file == */osx/* ]]; then
if [[ $OSTYPE == darwin* ]]; then
source_if_present $completion_file
fi
elif [[ $completion_file == */linux/* ]]; then
if [[ $OSTYPE == linux* ]]; then
source_if_present $completion_file
fi
else
source_if_present $completion_file
fi
done
# Load completion scripts
source_files_by_name "bash_completion"
139 changes: 99 additions & 40 deletions bash/prompt.bash
@@ -1,55 +1,114 @@
RED="\e[0;31m"
GREEN="\e[0;32m"
YELLOW="\e[0;33m"
BLUE="\e[0;34m"
PURPLE="\e[0;35m"
CYAN="\e[0;36m"
WHITE="\e[0;37m"
RESET="\e[0m"

directory_name () {
echo "\[$CYAN\]\w\[$RESET\]"
}
export PROMPT_COMMAND=__prompt_command

username () {
echo "\[$BLUE\]\u\[$RESET\]"
# Returns prompt encoded color.
# Takes 1 optional argument.
# If argument is provided, return color prompt. If argument is omitted, return reset.
get_prompt_color () {
if [[ -n $1 ]]; then
echo "\e[38;5;$1m"
else
echo '\e[0m'
fi
}

hostname () {
echo "\[$PURPLE\]\h\[$RESET\]"
}
# Memo-ized var
SEPARATOR=""

git_branch_name () {
ref=$(git symbolic-ref HEAD 2>/dev/null)
if [[ $ref == "" ]]; then
echo "#$(git describe)"
# Begin a segment
# Takes two arguments, foreground and message. Foreground can be omitted,
# rendering default foreground.
prompt_segment () {
local fg
local message

# If 2 params, 1st one is foreground
if [[ -n $2 ]]; then
# insert color supporting 256 colors
fg="$(get_prompt_color $1)"
message="$2"
else
echo "${ref#refs/heads/}"
fg="$(get_prompt_color)"
message="$1"
fi
}

git_commit_hash () {
echo "[$YELLOW$(git rev-parse --short HEAD)$RESET]"
# color the prompt, spit out the message and reset the colors
echo -n "$SEPARATOR$fg$message$(get_prompt_color)"

# Let this run after the first run
SEPARATOR=" "
}

git_branch () {
st=$(git status 2>/dev/null | tail -n 1)
if [[ $st == "" ]]; then
echo ""
else
if [[ $st == "nothing to commit (working directory clean)" ]]; then
echo -e " on $GREEN$(git_branch_name)$RESET$(git_commit_hash)"
else
echo -e " on $RED$(git_branch_name)$RESET$(git_commit_hash)"
build_prompt () {
local EXIT="$?"

# If exit status is non-zero show an x in red
if [ $EXIT != 0 ]; then
prompt_segment 1 ''
fi

if [[ -n "$SSH_CONNECTION" ]]; then
# username in blue
prompt_segment 4 '\u'
prompt_segment 'at'
# hostname in magenta
prompt_segment 5 '\h'
prompt_segment 'in'
fi

# Working directory in cyan
prompt_segment 6 '\w'

# If in a git repo
git_ref="$(git symbolic-ref HEAD 2>&1)"
if [[ $git_ref != fatal* ]]; then
# git branch in yellow and commit hash in default
prompt_segment 3 "$(git_branch_name $git_ref) [$(get_prompt_color)$(git_commit_hash)$(get_prompt_color 3)]"

# If git symbols has anything, show it in red
local git_symbols="$(git_status)"
if [[ $git_symbols != "" ]]; then
prompt_segment 1 "$git_symbols"
fi
fi

# cursor prompt in light blue
prompt_segment 12 "\n❯ "
}

git_branch_name () {
echo "${git_ref#refs/heads/}"
}

git_commit_hash () {
echo "$(git rev-parse --short HEAD)"
}

if [[ -n "$SSH_CONNECTION" ]]; then
export PS1="$(username) at $(hostname) in $(directory_name)\$(git_branch)\n› "
else
export PS1="in $(directory_name)\n› "
fi
git_status () {
local symbols
local git_st="$(git diff --name-status 2>&1)"

# If untracked files
[[ "$(git ls-files --others --exclude-standard $(git rev-parse --show-cdup))" != "" ]] && symbols+="?"

export PS2=""
# If modified files
[[ $(echo "$git_st" | egrep -c "^M") != 0 ]] && symbols+=""

# If modified files
[[ $(echo "$git_st" | egrep -c "^D") != 0 ]] && symbols+=""

# If added files
[[ "$(git diff --staged --name-status)" != "" ]] && symbols+=""

# If stashed
[[ "$(git stash list)" != "" ]] && symbols+="s"

echo "$symbols"
}

# helper function
count_lines() { echo "$1" | egrep -c "^$2" ; }

__prompt_command () {
export PS1="$(build_prompt)"
export PS2=""
}
23 changes: 0 additions & 23 deletions bash/window.bash

This file was deleted.

2 changes: 0 additions & 2 deletions bin/path

This file was deleted.

2 changes: 2 additions & 0 deletions boot2docker/init.sh
@@ -0,0 +1,2 @@
#Boot2Docker init
$(boot2docker shellinit 2>/dev/null)

0 comments on commit 117b891

Please sign in to comment.