Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Created July 15, 2009 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ratbeard/147824 to your computer and use it in GitHub Desktop.
Save ratbeard/147824 to your computer and use it in GitHub Desktop.
###########
# Dirs #
###########
export pdir='~/dev/project'
export gdir=`gem env gemdir` # /Library/Ruby/Gems/1.8/gems
export rdir='~/dev/repos'
alias cdp="cd $pdir" # projects
alias cdg="cd $gdir/gems" # gems
alias cdr="cd $rdir" # repos
alias cdn="cd ~/dev/note" # notes
# Current Projects:
alias cdpp="cd $pdir/pillarsoft"
# Cmds #
alias ls='ls -F'
alias l='ls -lah'
alias tm='mate'
alias ..='cd ..'
alias ...='cd ../..'
alias dus='du -Psckx * | sort -nr'
function manpdf() {
man -t $@ | open -f -a /Applications/Preview.app/
}
# copy current dir to clipboard
cwd() {
pwd | pbcopy
}
# go to current dir in clipboard
ppwd() {
cd `pbpaste`
}
########
# RUBY #
########
gemdoc() {
local gemdir=`gem env gemdir`
open $gemdir/doc/`ls $gemdir/doc/ | grep $1 | sort | tail -1`/rdoc/index.html
}
_gemdocomplete() {
COMPREPLY=($(compgen -W '$(ls `gem env gemdir`/doc)' -- ${COMP_WORDS[COMP_CWORD]}))
return 0
}
complete -o default -o nospace -F _gemdocomplete gemdoc
alias r="rake"
alias r?="rake -T | grep $1"
## Rails ##
alias mr='mate app config db lib public spec'
alias sg='ruby script/generate'
alias ss='ruby script/server'
alias sc='ruby script/console'
#######
# GIT #
#######
alias g='git'
alias gs='git status'
#
alias ga='git add .'
alias gc='git commit'
alias gca='git commit -a'
#
alias gco='git checkout'
alias gm='git merge'
alias gb='git branch'
alias gbn='git checkout -b'
alias gd='git diff'
alias gdm='git diff | mate'
#########
# NGINX #
#########
alias nginxe="cd /opt/nginx; mate conf logs sites-available sites-enabled/"
alias re="touch tmp/restart.txt"
############
# SETTINGS #
############
export EDITOR="/usr/bin/mate -w"
# Path #
PATH="/usr/local/bin:/usr/local/sbin:$PATH"
PATH="/usr/local/mysql/bin:$PATH" # mysql
PATH="/opt/local/bin:opt/local/sbin:$PATH" # macports
PATH="/opt/local/bind:/opt/local/sbin:$PATH" # macports installs
export PATH
MANPATH="$MANPATH:/opt/local/share/man" # macports
export MANPATH
# Bash Profile #
alias bashe='tm ~/.bashrc'
alias bashr='source ~/.bashrc'
basha() {
echo `pbpaste` >> ~/.bashrc
tail ~/.bashrc
}
### ENV ###
export GLOG_BOX="mike-laptop"
source ~/.connections
### PROMPT ###
# looks like:
# 571 ~/dev/project/pillarsoft $
# dir is in green
# export PS1="\! \e[0;32m\w\e[m $ "
# export PS1="\e[0;31m\!\e[m \e[0;36m\w\e[m \n\e[0;36m$\e[m "
# misc
NO_COLOR='\e[0m' #disable any colors
# regular colors
BLACK='\e[0;30m'
RED='\e[0;31m'
GREEN='\e[0;32m'
YELLOW='\e[0;33m'
BLUE='\e[0;34m'
MAGENTA='\e[0;35m'
CYAN='\e[0;36m'
WHITE='\e[0;37m'
# emphasized (bolded) colors
EBLACK='\e[1;30m'
ERED='\e[1;31m'
EGREEN='\e[1;32m'
EYELLOW='\e[1;33m'
EBLUE='\e[1;34m'
EMAGENTA='\e[1;35m'
ECYAN='\e[1;36m'
EWHITE='\e[1;37m'
# underlined colors
UBLACK='\e[4;30m'
URED='\e[4;31m'
UGREEN='\e[4;32m'
UYELLOW='\e[4;33m'
UBLUE='\e[4;34m'
UMAGENTA='\e[4;35m'
UCYAN='\e[4;36m'
UWHITE='\e[4;37m'
# background colors
BBLACK='\e[40m'
BRED='\e[41m'
BGREEN='\e[42m'
BYELLOW='\e[43m'
BBLUE='\e[44m'
BMAGENTA='\e[45m'
BCYAN='\e[46m'
BWHITE='\e[47m'
export PS1="\! \[$GREEN\]\w \[$NO_COLOR\]\n\[$GREEN\]»\[$NO_COLOR\] "
# Change tab title:
function set_window_and_tab_title
{
local title="$1"
if [[ -z "$title" ]]; then
title="root"
fi
local tmpdir=~/Library/Caches/${FUNCNAME}_temp
local cmdfile="$tmpdir/$title"
# Set window title
echo -n -e "\e]0;${title}\a"
# Set tab title
if [[ -n ${CURRENT_TAB_TITLE_PID:+1} ]]; then
kill $CURRENT_TAB_TITLE_PID
fi
mkdir -p $tmpdir
ln /bin/sleep "$cmdfile"
"$cmdfile" 10 &
CURRENT_TAB_TITLE_PID=$(jobs -x echo %+)
disown %+
kill -STOP $CURRENT_TAB_TITLE_PID
command rm -f "$cmdfile"
}
#PROMPT_COMMAND='set_window_and_tab_title "${PWD##*/}"'
# see http://troy.yort.com/short-fast-micro-whois
# 0 if available
# 1 if taken
d () {
# Append ".com" to input if doesn't contain a ".":
domain=$1
if [[ ! $1 =~ \.\w+$ ]]; then
domain=$domain.com
fi
result=`dig -t NS "$domain" | grep -c "ANSWER SECTION"`
# confirm with whois since some registered domains have no
# NS resource record in root servers
if [ "$result" = "0" ]; then
# -n not supported on osx :(
# result=`whois -n "$domain" | grep -c "Registrar: "`
# osx is:
dontknow="???"
fi
# Print result with color, as smiley!
if [ "$result" = "0" ]; then
echo -e '\e[0;32m:)\e[00m'
else
echo -e '\e[0;31m:(\e[00m'
fi
return $result
}
# Sources
# http://pastie.org/pastes/259210/edit - alot
# http://www.macosxhints.com/article.php?story=20031008142756724 - `dus`
# Change tab title:
# http://pseudogreen.org/blog/set_tab_names_in_leopard_terminal.html
# APPENDS #
export JEWELER_OPTS="--rspec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment