Skip to content

Instantly share code, notes, and snippets.

@chandu-io
Forked from digitaljhelms/.bashrc
Created July 3, 2013 18:57
Show Gist options
  • Save chandu-io/5921679 to your computer and use it in GitHub Desktop.
Save chandu-io/5921679 to your computer and use it in GitHub Desktop.
alias ls='ls -GA'
alias ll='ls -lGA'
alias l=ll
alias pwdc='pwd | pbcopy'
alias updatedb='sudo /usr/libexec/locate.updatedb'
# open applications
alias psd='open -a Adobe\ Photoshop\ CS5'
alias chrome='open -a Google\ Chrome'
# list all crontab jobs for all users
alias allcron='for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done'
# ack, ignore case, pipe output through "less" command and ignore redirects + chop long lines
alias ick='ack -i --pager="less -R -S"'
# cp w/ per-file progress indicator
#alias cp='rsync -WavP'
# cloud9ide
alias cloud9='node ~/Sandbox/cloud9/bin/cloud9.js'
# pretty JSON: "curl blah.com/blah.json | json"
alias json='python -m json.tool'
# fml
alias mage=mate
alias shh=ssh
# git + hub = github
eval "$(hub alias -s)"
# Git Command Completion & Git-aware PS1
source ~/.git-completion.bash
source ~/.git-prompt.sh
PS1='\h:\W$(__git_ps1 "(%s)") \u\$ '
# file/directory cleanup
function delstore() {
echo "recursively removing .DS_Store files from"
pwd
find . -name ".DS_Store" -delete
}
function delcvs() {
echo "recursively removing CVS folders from"
pwd
#rm -rf `find . -type d -name CVS`
find . -name CVS -print0 | xargs -0 rm -rf
}
function delgit() {
echo "recursively removing .git folders from"
pwd
#rm -rf `find . -type d -name .git`
find . -name .git -print0 | xargs -0 rm -rf
}
function delsvn() {
echo "recursively removing .svn folders from"
pwd
#rm -rf `find . -type d -name .svn`
find . -name .svn -print0 | xargs -0 rm -rf
}
function delorig() {
echo "recursively removing *.orig files from"
pwd
find . -name "*.orig" -delete
}
function delpyc() {
echo "recursively removing .pyc files from"
pwd
find . -name "*.pyc" -delete
}
# change file extension for multiple files at once
function ext() {
for f in *.$1; do mv $f `basename $f .$1`.$2; done;
}
# count the number of css selectors in a file
# usage: cat styles.css | csscount
# http://alias.sh/count-number-selectors-css-file
function csscount() {
local cnt=0
local depth=0
while read -n 1 char; do
case $char in
"{") ((depth++));;
"}")
((depth--))
if [ "$depth" -eq "0" ]; then
((cnt++))
fi
;;
",") ((cnt++));;
esac
done
echo $cnt
}
# ievms
#alias ievms='curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | bash'
function ievms() {
local ievms_opts
PS3="What version(s) of IE do you want to install? "
select VER in "IE 7" "IE 8" "IE 9" "All"; do
case $VER in
1) $ievms_opts="IEVMS_VERSIONS=\"7\"";; # only 7
2) $ievms_opts="IEVMS_VERSIONS=\"8\"";; # only 8
3) $ievms_opts="IEVMS_VERSIONS=\"9\"";; # only 9
4) ;; #this is default
*) echo "Invalid choice.";;
esac
if [ -n "$VER" -a "$VER" -le 4 ]; then
break
fi
done
echo "curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | $ievms_opts bash"
# if [ -n "$1"]; then # if there's an argument passed to the function
# case $1 in
# p) ;; # install to specific path
# v) ;; # install specific versions
# o) ;; # pass additional options to curl
# esac
# else
# # run ievms "as is"
# fi
}
# sublime text 2
alias subl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'
#alias st='subl'
function st() {
if [ -n "$1" -a -n "$2" ]; then # if more than one argument
if [ "$1" = "-p" -o "$1" = "--project" ]; then # if arg1 is -p or --project
local projectfile="$2"
[[ $projectfile != *.sublime-project ]] && projectfile="$2.sublime-project" # detect if arg2 already includes the ext
if [ -e $projectfile ]; then # does project file exist?
subl -n --project $projectfile ${*:3} # open project file, in new window, include trailing args
#echo "project specified, and project file exists, execute: subl -n --project projectfile ${*:3}"
else
subl ${*:3} # open sublime but drop -p||--project and project name from args
#echo "project specified, but project file doesn't exist, execute: subl ${*:3}"
fi
else
subl $* # open sublime and pass args as usual
#echo "project argument not passed, execute: subl $*"
fi
else
subl $* # open sublime and pass args as usual
#echo "only 1 argument passed, execute: subl $*"
fi
}
export -f st
# LS_COLORS
# http://softwaregravy.com/ls-colors-for-mac/
export LS_OPTIONS='--color=auto'
export CLICOLOR=1
# default is exfxcxdxbxegedabagacad
export LSCOLORS=Dxfxcxdxbxegedabagacad
# Default compiler
export CC=/usr/bin/gcc
# Default editor
#export EDITOR='coda -w'
#export EDITOR='mate -w'
export EDITOR='st -w'
# http://blog.vicshih.com/2008/04/move-to-trash-from-mac-command-line.html
#alias rm='trash'
function trash() {
while [ -n "$1" ]; do
local file=`basename "$1"`
# Chop trailing '/' if there
file=${file%/}
local destination=""
if [ -e "$HOME/.Trash/$file" ]; then
# Extract file and extension
local ext=`expr "$file" : ".*\(\.[^\.]*\)$"`
local base=${file%$ext}
# Add a space between base and timestamp
test -n "$base" && base="$base "
destination="/$base`date +%H-%M-%S`_$RANDOM$ext"
fi
echo "Moving '$1' to '$HOME/.Trash$destination'"
mv "$1" "$HOME/.Trash$destination"
shift
done
}
# Android SDK
export PATH="/Developer/SDKs/AndroidOSX.sdk/tools:/Developer/SDKs/AndroidOSX.sdk/platform-tools:$PATH"
# Python/Django
#export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages"
export PYTHONPATH="/Library/Python/2.7/site-packages:/Users/jhelms/Sandbox/django/trunk/django"
# Command completion for Django when using django-admin
. ~/Sandbox/django/trunk/extras/django_bash_completion
# local & sbin directory
#export PATH="/usr/local:/usr/local/bin:/usr/local/sbin:$PATH" # this is done in /etc/paths instead
# MySQL
#export PATH="/usr/local/mysql/bin:$PATH"
# PostgreSQL
#export PATH="/Library/PostgreSQL/9.0/bin:$PATH"
# Postgres.app
#export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
# Permanently set the SVN_EDITOR variable
export SVN_EDITOR=/usr/bin/vi
# virtualenvwrapper
export WORKON_HOME=$HOME/Sites/virtualenvs
source /usr/local/bin/virtualenvwrapper_bashrc
# Configure RVM
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
#PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
source $HOME/.rvm/scripts/rvm
# Grunt auto-completion
eval "$(grunt --completion=bash)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment