diff --git a/shell/_main.sh b/shell/_main.sh new file mode 100644 index 0000000..bf76cf8 --- /dev/null +++ b/shell/_main.sh @@ -0,0 +1,68 @@ +# +# Main Shell Setup +# + +# Set required path variables +DOTBIN="$DOTFILES/bin" + +# Helper Functions +source "$DOTSHELL/helpers.sh" + +# Ensure /usr/local/bin is before various system-paths +path_prepend "/usr/local/bin" + +# Load bash or zsh specific init files +if [ -n "$BASH_VERSION" ]; then + source "$DOTSHELL/bashrc.sh" +elif [ -n "$ZSH_VERSION" ]; then + source "$DOTSHELL/zshrc.sh" +fi + +# Aliases +source "$DOTSHELL/aliases.sh" + +# Utils +source "$DOTSHELL/emacs.sh" +source "$DOTSHELL/git.sh" +source "$DOTSHELL/tmux.sh" + +# Development +source "$DOTSHELL/nodejs.sh" +source "$DOTSHELL/python.sh" +source "$DOTSHELL/ruby.sh" + +# Services +source "$DOTSHELL/aws.sh" +source "$DOTSHELL/services.sh" + + +# +# Environment Setup +# + +# Editors +export EDITOR="emacsclient-wrapper" +export GEM_EDITOR="mate" + +# Locale Setup +export LC_ALL="en_US.UTF-8" +export LANG="en_US.UTF-8" + +# ensure bin and sbin paths from /usr/local are in PATH +path_add_after "/usr/local/sbin" "/usr/local/bin" + +# Add user's bin directory to PATH +path_prepend "$HOME/bin" + +# Add dotfiles' bin directory to PATH +path_prepend "$DOTBIN" + +# Relative Paths - must be first in PATH +path_prepend "./node_modules/.bin" # Node.js +path_prepend "./.bin" # Ruby Bundler + +# Ensure TMPDIR is the same for local and remote ssh logins +if [[ $TMPDIR == "/var/folders/"* ]] || [[ $TMPDIR == "" ]]; then + export TMPDIR="/tmp/user-$USER" + mkdir -p "$TMPDIR" +fi diff --git a/shell/aliases.sh b/shell/aliases.sh new file mode 100644 index 0000000..6c8846f --- /dev/null +++ b/shell/aliases.sh @@ -0,0 +1,23 @@ +# +# Aliases +# + +# System +alias o="open" +alias s="ssh" +alias ls="ls -BG" +alias ll="ls -lah" +alias duh="du -h" + +# Editors +alias n="nano" +alias t="mate" +alias e="$DOTBIN/emacsclient-wrapper" + +# Utils +alias br="brew" +alias devnullsmtp="java -jar $DOTBIN/DevNullSmtp.jar" + +# Misc. +alias slashdot="ab -kc 50 -t 300" +alias digg="ab -kc 50 -t 30" diff --git a/shell/bash/bash-ido.sh b/shell/bash/bash-ido.sh new file mode 100644 index 0000000..fe2d758 --- /dev/null +++ b/shell/bash/bash-ido.sh @@ -0,0 +1,374 @@ +## bash-ido - attempt to simulate a interactive menu similar to +# ido-mode in emacs +# +# URL: http://pgas.freeshell.org/shell/bash-ido + +# Author: +# Version: 1.0beta2 +# CVS: $Id: bash-ido,v 1.18 2010/02/13 14:50:32 pgas Exp $ + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BASH-IDO; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# + +# Documentation: +# -------------- + +# This is a fairly complex completion script for cd. (For now, i tried +# to make the functions a bit generic so that the menu can be used for +# other completions. Let me know if you need some help or something) +# It mimics what ido-mode does in emacs.This script also masks the +# normal cd with a function to track the list of the directory +# used. It's easier to try than to describe, here is a little getting +# started: +# +# 0) Source this script in your .bashrc (. /path/to/bash-ido) +# 1) Start your cd command, press TAB, type some letters the list of dirs is +# filtered according to these letters. +# 2) Press RET to select the first dir in the list. +# 3) DEL ie the erase key (usually backspace or ^H), to delete a search letter. +# When there are no more letters, pressing DEL let you go up one dir. +# 4) C-s or cycles the list to the right, C-r or to the left +# 5) C-g or C-c cancels the completion. +# 6) Typing 2 / will put you in /, typing /~/ will put you in $HOME +# 7) up/M-s and down/M-r allows to navigate in the history + +# Limitations +# ----------- +# * You cannot start completion after a dirname in " " or ' ' +# (actually it's probably possible if you modify COMP_WORDBREAKS) +# * It doesn't expand the ~user/ dirs, if you need this please tell me +# * The completion disables and re-enables C-c using stty, +# if you use another char for intr you need to modify +# the hard coded value (search for $'\003') this could be found via stty +# or a parameter could be defined but how well....tell me if you feel this +# is needed. +# * It probably doesn't work too well with huge dirs (a security check could +# perhaps be implemented). + +# Implementation Notes: +# --------------------- +# * Not sure what bash version is required. +# * It Probably doesn't work too well with some strange filenames. +# * All the functions and variables in this file should be prefixed by _ido_ +# to avoid namespace polution +# * Use stty rather than a trap to disable sigint....I couldn't do what +# I wanted with trap. +# * I choose to use the hardcoded ansi codes rather than tput, it should be +# a tad faster and reduce the dependencies, if you it doesn't work in your +# terminal please tell me. + +# TODO: +# ----- +# * add an example for other completions +# * support for CDPATH in dir completion? +# * implement persitent history? +# * complete on ~ first and handle ~user? + +# Global vars +# ----------- +# _ido_menu -- the list of choices +# _ido_f_menu -- the filtered menu +# _ido_search_string -- the characters typed so far +# _ido_result -- the dirname part of the search + _ido_history_size=100 # -- maximum dir entries in the history +# _ido_history -- list of the directories in the history +# _ido_history_point -- pointer to the current history entry + +# Functions +# --------- +# _ido_print_menu -- print the filtered menu +# _ido_loop -- the main keyboard event loop +# _ido_filter -- filters the menu +# _ido_gen_dir -- generate the original menu (list of dirs) +# _ido_dir -- entry point + +# Changes +# ------- +# 1.0b2 +# * fix ../ behaviour +# * fix TAB behaviour + +shopt -s checkwinsize #so that COLUMNS stays up to date + +_ido_print_f_menu () { + # Prints the directories limited on one line... + # We would need some terminal commands to clear more than one line + local prompt menu i cur + prompt=${_ido_result}${_ido_search_string} + if (( ${#_ido_f_menu[@]} ));then + menu="{ ${_ido_f_menu[0]#* }" + i=1 + while cur=${_ido_f_menu[i]#* }; + (( i < (${#_ido_f_menu[@]} -1) + && (${#menu}+${#prompt} +${#cur}+11) < COLUMNS )) \ + || (( i == (${#_ido_f_menu[@]} -1) + && (${#menu}+${#prompt}+${#cur}+4) < COLUMNS)); do + menu+=" | ${cur}" + i=$((i+1)) + done + if ((i < (${#_ido_f_menu[@]} -1) )) ; then + menu+=" | ... }" + else + menu+=" }" + fi + #yet another hack to put the cursor after the search string. + printf "\r%*s\r%*s%s\r%s" $COLUMNS " " ${#prompt} " " "$menu" "$prompt" + else + printf "\r%*s\r%*s%s\r%s" $COLUMNS " " ${#prompt} " " "[ No Match]" "$prompt" + fi +} + +_ido_filter () { + local i start trans_i cas quoted + if shopt -q nocasematch;then + cas=set + else + shopt -s nocasematch + fi + start=${_ido_f_menu[i]%% *} + unset _ido_f_menu + if [[ "$_ido_search_string" ]];then + printf -v quoted "%q" "$_ido_search_string" + else + quoted="" + fi + for i in "${!_ido_menu[@]}";do + trans_i=$(((i+start)%${#_ido_menu[@]})) + if [[ "${_ido_menu[trans_i]}" = *"$quoted"* ]];then + _ido_f_menu+=( "$trans_i ${_ido_menu[trans_i]}" ) + fi + done + if [[ -z $cas ]];then + shopt -u nocasematch + fi +} + +_ido_loop () { + local REPLY c + while :;do + _ido_print_f_menu >&2 + unset c + while :;do + #loop to read the escape sequences + IFS= read -d '' -r -s -n 1 + case $REPLY in + $'\E') + c+=$REPLY + ;; + \[|O) + c+=$REPLY + if ((${#c} ==1));then + break + fi + ;; + *) + c+=$REPLY + break + ;; + esac + done + case $c in + $'\n'|$'\t') # RET + _ido_result="${_ido_result}${_ido_f_menu[0]#* }" + return 0 + ;; + / ) # / + case $_ido_search_string in + ..) + _ido_result+="../" + ;; + \~) + _ido_result="$HOME/" + ;; + ?*) + _ido_result="${_ido_result}${_ido_f_menu[0]#* }" + ;; + *) + _ido_result=/ + ;; + esac + return 0 + ;; + '$\b'|$'\177') #DEL aka ^? or ^h + if [[ $_ido_search_string ]]; then + _ido_search_string=${_ido_search_string%?} + _ido_filter + else + _ido_result+="../" + return 0 + fi + ;; + $'\a' | $'\003') # C-g | C-c + return 2 + ;; + $'\E[C'|$'\EOC'|$'\023') # | C-s + if ((${#_ido_f_menu[@]}>1));then + _ido_f_menu=("${_ido_f_menu[@]:1}" "${_ido_f_menu[0]}") + fi + ;; + $'\E[D'|$'\EOD'|$'\022') # | C-r + if ((${#_ido_f_menu[@]}>1));then + _ido_f_menu=("${_ido_f_menu[${#_ido_f_menu[@]}-1]}" + "${_ido_f_menu[@]:0:${#_ido_f_menu[@]}-1}") + fi + ;; + $'\E[B'|$'\EOB'|$'\367'|$'\Er') # | M-r + if ((_ido_history_point>1));then + _ido_history_point=$((_ido_history_point-1)) + _ido_result=${_ido_history[_ido_history_point]%/}/ + _ido_search_string="" + return 0 + else + printf "\a" >&2 + fi + ;; + $'\E[A'|$'\EOA'|$'\362'|$'\Es') # | M-s + if (((_ido_history_point+1)< ${#_ido_history[@]}));then + _ido_history_point=$((_ido_history_point+1)) + _ido_result=${_ido_history[_ido_history_point]%/}/ + _ido_search_string="" + return 0 + else + printf "\a" >&2 + fi + ;; + [[:print:]]) + _ido_search_string+=$REPLY + _ido_filter + ;; + *) + printf "\a" >&2 +# printf "%q\n" "$c" + ;; + esac + done +} + +_ido_gen_dir () { + # return a list of subdir in _ido_result, + local pattern + case $_ido_search_string in + ..) + pattern=../ + ;; + .) + pattern="./ ..?*/ .[!.]*/ */" + ;; + .?*) + pattern="..?*/ .[!.]*/ */" + ;; + *) + pattern="./ */ ..?*/ .[!.]*/" + ;; + esac + _ido_result=${_ido_result/#~\//$HOME/} + unset _ido_menu + IFS=$'\n' read -r -d '' -a _ido_menu \ + < <(IFS=" ";shopt -s nullglob;\ + eval command cd "$_ido_result" 2>/dev/null \ + && printf -- "%q\n" $pattern) + if [[ $_ido_search_string ]];then + _ido_filter + else + local i e + unset _ido_f_menu + for e in "${_ido_menu[@]}";do + _ido_f_menu[i]="$i $e" + i=$((i+1)) + done + fi + _ido_result="${_ido_result/#$HOME\//~/}" +} + +_ido_dir () { + _ido_result=${COMP_WORDS[COMP_CWORD]} + + if [[ "$_ido_result" == \$* ]]; then + if [[ "$_ido_result" == */* ]];then + local temp + temp=${_ido_result%%/*} + temp=${temp#?} + _ido_result=${!temp}/${_ido_result#*/} + else + COMPREPLY=( $( compgen -v -P '$' -- "${_ido_result#$}" ) ) + return 0 + fi + fi + stty intr undef + local status + unset _ido_f_menu _ido_search_string _ido_history_point + printf '\E7' #tput sc = save cursor + status=0 + case $_ido_result in + ''|.|./ ) + _ido_result=$PWD/ + ;; + */*) + _ido_search_string=${_ido_result##*/} + _ido_result=${_ido_result%/*}/ + _ido_result=${_ido_result/#~\//$HOME/} + if [[ ! -d ${_ido_result} ]]; then + printf "\a\nNo Such Directory: %s\n" "${_ido_result}" >&2 + status=1 + fi + ;; + *) + _ido_search_string=$_ido_result + _ido_result=$PWD/ + ;; + esac + # normalize ie remove the // and other foo/../bar + _ido_result=$(command cd "$_ido_result" && printf "%q" "${PWD%/}/") + while [[ $status = 0 && $_ido_result != */./ ]]; do + # hmm this part is dir specific...TB generalized.. + case $_ido_result in + # order is important, the last case covers the first ones + /../) + _ido_result=/ + ;; + \~/../) + _ido_result=${HOME%/*}/ + ;; + */../) + _ido_result=${_ido_result%/*/../}/ + ;; + esac + _ido_gen_dir + _ido_loop; status=$? + _ido_search_string="" + + done + printf "\r%*s\E8" $COLUMNS # clear the line, tput rc restore the cursor + kill -WINCH $$ # force bash to redraw + stty intr $'\003' + if [[ $status = 0 ]]; then + # gives the _ido_result to bash + COMPREPLY[0]=${_ido_result%./} + fi + return $status +} + +complete -F _ido_dir -o nospace cd + +cd () { + if command cd "$@";then + _ido_history=($(printf "%s\n" "$PWD" "${_ido_history[@]}" |\ + awk -v s="$_ido_history_size" '!a[$0]++;(i++==s-1){exit}')) + fi +} +### Local Variables: +### mode: shell-script +### End: diff --git a/shell/bash/colors.sh b/shell/bash/colors.sh new file mode 100644 index 0000000..9a023ac --- /dev/null +++ b/shell/bash/colors.sh @@ -0,0 +1,33 @@ +txtblk='\e[0;30m' # Black - Regular +txtred='\e[0;31m' # Red +txtgrn='\e[0;32m' # Green +txtylw='\e[0;33m' # Yellow +txtblu='\e[0;34m' # Blue +txtpur='\e[0;35m' # Purple +txtcyn='\e[0;36m' # Cyan +txtwht='\e[0;37m' # White +bldblk='\e[1;30m' # Black - Bold +bldred='\e[1;31m' # Red +bldgrn='\e[1;32m' # Green +bldylw='\e[1;33m' # Yellow +bldblu='\e[1;34m' # Blue +bldpur='\e[1;35m' # Purple +bldcyn='\e[1;36m' # Cyan +bldwht='\e[1;37m' # White +unkblk='\e[4;30m' # Black - Underline +undred='\e[4;31m' # Red +undgrn='\e[4;32m' # Green +undylw='\e[4;33m' # Yellow +undblu='\e[4;34m' # Blue +undpur='\e[4;35m' # Purple +undcyn='\e[4;36m' # Cyan +undwht='\e[4;37m' # White +bakblk='\e[40m' # Black - Background +bakred='\e[41m' # Red +badgrn='\e[42m' # Green +bakylw='\e[43m' # Yellow +bakblu='\e[44m' # Blue +bakpur='\e[45m' # Purple +bakcyn='\e[46m' # Cyan +bakwht='\e[47m' # White +txtrst='\e[0m' # Text Reset diff --git a/shell/bash/helpers.sh b/shell/bash/helpers.sh new file mode 100644 index 0000000..662ceb2 --- /dev/null +++ b/shell/bash/helpers.sh @@ -0,0 +1,22 @@ +# +# Bash Helpers +# + +function find_git_branch { + local dir=. head + until [ "$dir" -ef / ]; do + if [ -f "$dir/.git/HEAD" ]; then + head=$(< "$dir/.git/HEAD") + if [[ $head == ref:\ refs/heads/* ]]; then + git_branch=" (${head#*/*/})" + elif [[ $head != '' ]]; then + git_branch=' (detached)' + else + git_branch=' (unknown)' + fi + return + fi + dir="../$dir" + done + git_branch='' +} diff --git a/shell/bash/prompt.sh b/shell/bash/prompt.sh new file mode 100644 index 0000000..994aed1 --- /dev/null +++ b/shell/bash/prompt.sh @@ -0,0 +1,12 @@ +# +# Bash Prompt +# + +PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND" + +# Git enabled prompt +export PS1="\[$txtrst\]\u@\h \w\[$txtcyn\]\$git_branch\[$txtrst\]\$ " +export SUDO_PS1="\[$txtrst\]\[$bakred\]\u@\h\[$txtrst\] \w\$ " + +# Customize prompt to act like pre-leopard +# PS1='\h:\w \u$ ' diff --git a/shell/bashrc.sh b/shell/bashrc.sh new file mode 100644 index 0000000..aefae9a --- /dev/null +++ b/shell/bashrc.sh @@ -0,0 +1,11 @@ +# +# Bash Init +# + +# Deterimine current directory +DOTBASH="$DOTSHELL/bash" + +source "$DOTBASH/helpers.sh" +source "$DOTBASH/colors.sh" +source "$DOTBASH/prompt.sh" +# source "$DOTBASH/bash-ido.sh" diff --git a/shell/emacs.sh b/shell/emacs.sh new file mode 100644 index 0000000..0d77116 --- /dev/null +++ b/shell/emacs.sh @@ -0,0 +1,10 @@ +# +# Emacs +# + +if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then + alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw" +fi +if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then + alias emacsclient="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" +fi diff --git a/shell/git.sh b/shell/git.sh new file mode 100755 index 0000000..9973364 --- /dev/null +++ b/shell/git.sh @@ -0,0 +1,31 @@ +# +# Git +# + +# Author name +export GIT_AUTHOR_NAME="`git config user.name`" +export GIT_AUTHOR_EMAIL="`git config user.email`" + +# Aliases +alias g="git" +alias gi="git" +alias ga="git add" +alias gs="git status" +alias gai="git add -i" +alias gp="git push" +alias gf="git fetch" +alias gd="git difftool" +alias gpl="git pull --rebase" +alias gix="gitx" +alias gx="gitx" + +# Git Completion +if [ -f "/usr/local/etc/bash_completion.d/git-completion.bash" ]; then + source "/usr/local/etc/bash_completion.d/git-completion.bash" +fi + +# Only needed for Bash. Zsh is much smarter with it's auto-completion ^_^ +if [ -n "$BASH_VERSION" ]; then + complete -o default -o nospace -F _git g + complete -o default -o nospace -F _git gi +fi diff --git a/shell/helpers.sh b/shell/helpers.sh new file mode 100644 index 0000000..f7b4a11 --- /dev/null +++ b/shell/helpers.sh @@ -0,0 +1,8 @@ +# +# Helper Functions +# + +DOTHELPERS="$DOTSHELL/helpers" + +# Load helpers +source "$DOTHELPERS/path_helpers.sh" diff --git a/shell/helpers/path_helpers.sh b/shell/helpers/path_helpers.sh new file mode 100644 index 0000000..fecad2a --- /dev/null +++ b/shell/helpers/path_helpers.sh @@ -0,0 +1,148 @@ +# +# PATH Helpers +# +# A few useful functions to manipulate the PATH environment variable. Use, +# modify, copy, steal, plunder these functions to your hearts content, at +# your own risk of course :) --jimeh +# + + +# Print PATH as a newline separated list. +# +# Example: +# +# $ echo $PATH +# /usr/bin:/usr/local/bin +# $ path_list +# /usr/bin +# /usr/local/bin +# +path_list () { + echo -n "$PATH" | tr ":" "\n" +} + +# Append specified path to the end of PATH. +# +# Takes one argument: +# - $1: path to add +# +# If $1 already exists it is first removed, and then added to the end of PATH. +# +# Example: +# +# $ echo $PATH +# /usr/bin:/usr/local/bin +# $ path_append "/usr/sbin" +# $ echo $PATH +# /usr/bin:/usr/local/bin:/usr/sbin +# +path_append () { + if [ ! -n "$1" ]; then return 2; fi + path_remove "$1"; + export PATH="$PATH:$1"; +} + +# Prepend specified path to the begnning of PATH. +# +# Takes one argument: +# - $1: path to add +# +# If $1 already exists it is first removed, and then added to the beginning of +# PATH. +# +# Example: +# +# $ echo $PATH +# /usr/bin:/usr/local/bin +# $ path_prepend "/usr/sbin" +# $ echo $PATH +# /usr/sbin:/usr/bin:/usr/local/bin +# +path_prepend () { + if [ ! -n "$1" ]; then return 2; fi + path_remove "$1"; + export PATH="$1:$PATH"; +} + +# Remove specified path from PATH. +# +# Takes one argument: +# - $1: path to remove +# +# Example: +# +# $ echo $PATH +# /usr/bin:/usr/local/bin +# $ path_remove "/usr/local/bin" +# $ echo $PATH +# /usr/bin +# +path_remove () { + if [ ! -n "$1" ]; then return 2; fi + if [[ ":$PATH:" == *":$1:"* ]]; then + export PATH=$(__path_clean `echo -n ":$PATH:" | sed "s;:$1;;"`) + return 0 + fi + return 1 +} + +# Add a path to PATH before another path. +# +# Takes two arguments: +# - $1: path to add +# - $2: target path to add $1 before +# +# If $1 already exists in PATH it is first removed, and then added before $2. +# +# Example: +# +# $ echo $PATH +# /usr/bin:/usr/local/bin +# $ path_add_before "/usr/local/sbin" "/usr/local/bin" +# $ echo $PATH +# /usr/bin:/usr/local/sbin:/usr/local/bin +# +path_add_before () { + if [ ! -n "$1" ] || [ ! -n "$2" ]; then return 2; fi + if [[ ":$PATH:" == *":$2:"* ]]; then + path_remove "$1" + export PATH=$(__path_clean `echo -n ":$PATH:" | sed "s;:$2;:$1:$2;"`) + return 0 + fi + return 1 +} + +# Add a path to PATH after another path. +# +# Takes two arguments: +# - $1: path to add +# - $2: target path to add $1 after +# +# If $1 already exists in PATH it is first removed, and then added after $2. +# +# Example: +# +# $ echo $PATH +# /usr/bin:/usr/local/bin +# $ path_add_before "/usr/local/sbin" "/usr/local/bin" +# $ echo $PATH +# /usr/bin:/usr/local/bin:/usr/local/sbin +# +path_add_after () { + if [ ! -n "$1" ] || [ ! -n "$2" ]; then return 2; fi + if [[ ":$PATH:" == *":$2:"* ]]; then + path_remove "$1" + export PATH=$(__path_clean `echo -n ":$PATH:" | sed "s;:$2;:$2:$1;"`) + return 0 + fi + return 1 +} + +# Strips first and last character from intput string. +# +# Example: +# __path_clean ":/bin:/usr/bin:" #=> /bin:/usr/bin +# +__path_clean () { + echo -n "$1" | sed "s/.\(.*\)./\1/" +} diff --git a/shell/nodejs.sh b/shell/nodejs.sh new file mode 100644 index 0000000..ae9aa96 --- /dev/null +++ b/shell/nodejs.sh @@ -0,0 +1,8 @@ +# +# Node.js +# + +# Load nvm if it's available +if [ -f "$HOME/.nvm/nvm.sh" ]; then + source "$HOME/.nvm/nvm.sh" +fi diff --git a/shell/python.sh b/shell/python.sh new file mode 100644 index 0000000..7ca6ed1 --- /dev/null +++ b/shell/python.sh @@ -0,0 +1,8 @@ +# +# Python +# + +# Load virtualenv-burrito if it's available +if [ -f "$HOME/.venvburrito/startup.sh" ]; then + source "$HOME/.venvburrito/startup.sh" +fi diff --git a/shell/ruby.sh b/shell/ruby.sh new file mode 100644 index 0000000..26588ca --- /dev/null +++ b/shell/ruby.sh @@ -0,0 +1,28 @@ +# Aliases +alias po="powify" +alias lu="lunchy" + +# Bundler aliases +alias bi="bundle install --path vendor/bundle --binstubs=.bin" +alias bc="bundle check" +alias bl="bundle list" +alias be="bundle exec" +alias bu="bundle update" +alias bco="bundle console" + +# Bundler aliases for specific ruby commands +alias ru="bundle exec ruby" +alias ra="bundle exec rake" +alias rai="bundle exec rails" +alias rs="bundle exec rspec" +alias ca="bundle exec cap" +alias cu="bundle exec cucumber" +alias va="bundle exec vagrant" + +# Load rbenv or RVM depending on which is available +if [ -d "$HOME/.rbenv/bin" ]; then + export PATH="$HOME/.rbenv/bin:$PATH" + eval "$(rbenv init -)" +elif [ -s "$HOME/.rvm/scripts/rvm" ]; then + source "$HOME/.rvm/scripts/rvm" +fi diff --git a/shell/services.sh b/shell/services.sh new file mode 100644 index 0000000..837a07e --- /dev/null +++ b/shell/services.sh @@ -0,0 +1,32 @@ +# Flush DNS cache +alias flush_dns="dscacheutil -flushcache" + +# Apache related +alias start_apache="sudo apachectl start" +alias stop_apache="sudo apachectl stop" +alias restart_apache="sudo apachectl restart" + +# NAMED DNS Server +NAMED_LAUNCHD_CONFIG="/System/Library/LaunchDaemons/org.isc.named.plist" +alias start_named="sudo launchctl load $NAMED_LAUNCHD_CONFIG" +alias stop_named="sudo launchctl unload $NAMED_LAUNCHD_CONFIG" +alias restart_named="stop_named; start_named" +alias reload_dns="restart_named" # legacy + +# Memcache related +MEMCACHED_LAUNCHD_CONFIG="~/Library/LaunchAgents/com.danga.memcached.plist" +alias start_memcached="launchctl load -w $MEMCACHED_LAUNCHD_CONFIG" +alias stop_memcached="launchctl unload -w $MEMCACHED_LAUNCHD_CONFIG;" +alias restart_memcached="stop_memcached; start_memcached" + +# MySQL related +MYSQL_LAUNCHD_CONFIG="~/Library/LaunchAgents/com.mysql.mysqld.plist" +alias start_mysql="launchctl load -w $MYSQL_LAUNCHD_CONFIG" +alias stop_mysql="launchctl unload -w $MYSQL_LAUNCHD_CONFIG;" +alias restart_mysql="stop_mysql; start_mysql" + +# Redis related +REDIS_LAUNCHD_CONFIG="~/Library/LaunchAgents/io.redis.redis-server.plist" +alias start_redis="launchctl load -w $REDIS_LAUNCHD_CONFIG" +alias stop_redis="launchctl unload -w $REDIS_LAUNCHD_CONFIG;" +alias restart_redis="stop_redis; start_redis" diff --git a/shell/svn.sh b/shell/svn.sh new file mode 100644 index 0000000..ccf828d --- /dev/null +++ b/shell/svn.sh @@ -0,0 +1,3 @@ +# Aliases +alias svnadderall="svn status | grep '^?' | cut -b 8- | xargs svn add" +alias svnridallin="svn status | grep '^!' | cut -b 8- | xargs svn remove --keep-local" diff --git a/shell/tmux.sh b/shell/tmux.sh new file mode 100644 index 0000000..452dd68 --- /dev/null +++ b/shell/tmux.sh @@ -0,0 +1,10 @@ +# Aliases +alias tm="tmux" +alias tma="tm att" +alias tmn="tm new" +alias tml="tm ls" + +# Tmux Completion +if [ -f "/usr/local/etc/bash_completion.d/tmux" ]; then + source "/usr/local/etc/bash_completion.d/tmux" +fi diff --git a/shell/zshrc.sh b/shell/zshrc.sh new file mode 100644 index 0000000..04a26ac --- /dev/null +++ b/shell/zshrc.sh @@ -0,0 +1,44 @@ +# +# Z-Shell Init +# + +# Export path variables +DOTZSH="$DOTSHELL/zsh" + +# Path to your oh-my-zsh configuration. +ZSH="$DOTZSH/oh-my-zsh" + +# Set name of the theme to load. +# Look in ~/.oh-my-zsh/themes/ +# Optionally, if you set this to "random", it'll load a random theme each +# time that oh-my-zsh is loaded. +ZSH_THEME="plain" + +# Set to this to use case-sensitive completion +# CASE_SENSITIVE="true" + +# Comment this out to disable weekly auto-update checks +DISABLE_AUTO_UPDATE="true" + +# Uncomment following line if you want to disable colors in ls +# DISABLE_LS_COLORS="true" + +# Uncomment following line if you want to disable autosetting terminal title. +DISABLE_AUTO_TITLE="true" + +# Uncomment following line if you want red dots to be displayed while waiting for completion +# COMPLETION_WAITING_DOTS="true" + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Example format: plugins=(rails git textmate ruby lighthouse) +plugins=(cap brew bundler gem heroku osx thor vagrant ruby rails3 powder python cake node) + +source "$ZSH/oh-my-zsh.sh" + +# Customize to your needs... + +# Disable shared history +unsetopt share_history + +# Cause I hit emacs shorts too much +bindkey -s "\C-x\C-f" "cd " diff --git a/shellrc.sh b/shellrc.sh new file mode 100644 index 0000000..9330ef6 --- /dev/null +++ b/shellrc.sh @@ -0,0 +1,22 @@ +# +# Shell Init +# + +# Set path to root of dotfiles +if [ -n "${BASH_SOURCE[0]}" ]; then + DOTFILES="`dirname \"${BASH_SOURCE[0]}\"`" +elif [ -n "$0" ]; then + DOTFILES="`dirname \"$0\"`" +fi + +# # Load main dotfiles +DOTSHELL="$DOTFILES/shell" +if [ -f "$DOTSHELL/_main.sh" ]; then + source "$DOTSHELL/_main.sh" +fi + +# # Setup and load private dotfiles +DOTPFILES="$DOTFILES/private" +if [ -f "$DOTPFILES/shellrc.sh" ]; then + source "$DOTPFILES/shellrc.sh" +fi