-
-
Save greyblue9/db4c8a9e0357ff4e74f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EDITOR=vi | |
export EDITOR='vim' | |
export CLICOLOR=1; | |
export LSCOLORS=exfxcxdxbxegedabagacad; | |
PATH=.:~/bin:/usr/local/mysql/bin:/usr/local/bin:~/local/node/bin:$PATH | |
alias ll="ls -golAF" | |
alias lll="ls -lAF" | |
alias ..="cd .." | |
alias clr="clear" | |
alias mvim="/Applications/MacVim/mvim" | |
alias py="python3" | |
# alias tar="tar -cvzf " | |
alias up="svn up" | |
alias tm="mate" | |
alias encrypt="echo openssl des3 -salt -in file.txt -out encryptedfile.txt" | |
alias decrypt="echo openssl des3 -d -salt -in encryptedfile.txt -out file.txt" | |
alias gs="git status " | |
alias ga="git add " | |
alias gb="git branch " | |
alias gc="git commit " | |
alias gd="git diff " | |
alias go="git checkout " | |
alias gk="gitk --all&" | |
alias gx="gitx --all" | |
alias pa="echo \"${PATH//:/$'\n'}\" | awk '!_[$0]++'" | |
# Place a return before each prompt and display the current working directory | |
PS1="\n\W \$ " | |
# This loads RVM into a shell session. | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" | |
function enc() { | |
openssl des3 -salt -in $1 -out $2 | |
} | |
function dec() { | |
openssl des3 -d -salt -in $1 -out $2 | |
} | |
# Setting PATH for Python 3.2 | |
# The orginal version is saved in .bash_profile.pysave | |
PATH="/Library/Frameworks/Python.framework/Versions/3.2/bin:${PATH}" | |
GROOVY_HOME=/usr/share/groovy; export GROOVY_HOME | |
PATH=$GROOVY_HOME/bin:$PATH; export PATH | |
export PATH | |
## | |
# Your previous /Users/chuck/.bash_profile file was backed up as /Users/chuck/.bash_profile.macports-saved_2013-07-18_at_16:17:40 | |
## | |
# MacPorts Installer addition on 2013-07-18_at_16:17:40: adding an appropriate PATH variable for use with MacPorts. | |
export PATH=/opt/local/bin:/opt/local/sbin:$PATH | |
# Finished adapting your PATH environment variable for use with MacPorts. | |
# Setting PATH for Python 3.4 | |
# The orginal version is saved in .bash_profile.pysave | |
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}" | |
export PATH | |
if [ -f ~/.git-completion.bash ]; then | |
. ~/.git-completion.bash | |
fi | |
# From https://gist.github.com/derekwyatt/1154129 | |
export DIRSTACK_MAX=15 | |
DS=() | |
function eecho | |
{ | |
echo $@ 1>&2 | |
} | |
function shiftStackUp | |
{ | |
typeset num=$1 | |
typeset -i c=$((num+1)) | |
while (( $c < ${#DS[*]} )) | |
do | |
DS[$((c-1))]="${DS[$c]}" | |
((c=c+1)) | |
done | |
unset DS[$((${#DS[*]}-1))] | |
} | |
function shiftStackDown | |
{ | |
typeset num=$1 | |
typeset -i c=${#DS[*]} | |
while (( $c > $num )) | |
do | |
DS[$c]="${DS[$((c-1))]}" | |
((c=c-1)) | |
done | |
} | |
function popStack | |
{ | |
if [[ ${#DS[*]} == 0 ]]; then | |
eecho "Cannot pop stack. No elements to pop." | |
return 1 | |
fi | |
typeset retv="${DS[0]}" | |
shiftStackUp 0 | |
echo $retv | |
} | |
function pushStack | |
{ | |
typeset newvalue="$1" | |
typeset -i c=0 | |
while (( $c < ${#DS[*]} )) | |
do | |
if [[ "${DS[$c]}" == "$newvalue" ]]; then | |
shiftStackUp $c | |
else | |
((c=c+1)) | |
fi | |
done | |
shiftStackDown 0 | |
DS[0]="$newvalue" | |
if [[ ${#DS[*]} -gt $DIRSTACK_MAX ]]; then | |
unset DS[$((${#DS[*]}-1))] | |
fi | |
} | |
function cd_ | |
{ | |
typeset ret=0 | |
if [ $# == 0 ]; then | |
pd "$HOME" | |
ret=$? | |
elif [[ $# == 1 && "$1" == "-" ]]; then | |
pd | |
ret=$? | |
elif [ $# -gt 1 ]; then | |
typeset from="$1" | |
typeset to="$2" | |
typeset c=0 | |
typeset path= | |
typeset x=$(pwd) | |
typeset numberOfFroms=$(echo $x | tr '/' '\n' | grep "^$from$" | wc -l) | |
while [ $c -lt $numberOfFroms ] | |
do | |
path= | |
typeset subc=$c | |
typeset tokencount=0 | |
for subdir in $(echo $x | tr '/' '\n' | tail -n +2) | |
do | |
if [[ "$subdir" == "$from" ]]; then | |
if [ $subc -eq $tokencount ]; then | |
path="$path/$to" | |
subc=$((subc+1)) | |
else | |
path="$path/$from" | |
tokencount=$((tokencount+1)) | |
fi | |
else | |
path="$path/$subdir" | |
fi | |
done | |
if [ -d "$path" ]; then | |
break | |
fi | |
c=$((c=c+1)) | |
done | |
if [ "$path" == "$x" ]; then | |
echo "Bad substitution" | |
ret=1 | |
else | |
pd "$path" | |
ret=$? | |
fi | |
else | |
pd "$1" | |
ret=$? | |
fi | |
return $ret | |
} | |
function pd | |
{ | |
typeset dirname="${1-}" | |
typeset firstdir seconddir ret p oldDIRSTACK | |
if [ "$dirname" == "" ]; then | |
firstdir=$(pwd) | |
if [ ${#DS[*]} == 0 ]; then | |
eecho "Stack is empty. Cannot swap." | |
return 1 | |
fi | |
seconddir=$(popStack) | |
pushStack "$firstdir" | |
"cd" "$seconddir" | |
ret=$? | |
return $ret | |
else | |
if [ -d "$dirname" ]; then | |
if [ "$dirname" != '.' ]; then | |
pushStack "$(pwd)" | |
fi | |
"cd" "$dirname" | |
ret=$? | |
return $ret | |
else | |
eecho "bash: $dirname: not found" | |
return 1 | |
fi | |
fi | |
} | |
function ss | |
{ | |
typeset f x | |
typeset -i c=0 | |
typeset re="${1-}" | |
while (( $c < ${#DS[*]} )) | |
do | |
f=${DS[$c]} | |
if [[ -n "$re" && "$(echo $f | grep $re)" == "" ]]; then | |
((c=c+1)) | |
continue | |
fi | |
if (( ${#f} > 120 )); then | |
x="...$(echo $f | cut -c$((${#f}-120))-)" | |
else | |
x=$f | |
fi | |
echo "$((c+1))) $x" | |
((c=c+1)) | |
done | |
} | |
function csd | |
{ | |
typeset num=${1-} | |
typeset removedDirectory | |
# if [ "${num##+([0-9])}" != "" ]; then | |
if [ "$(echo $num | sed 's/^[0-9]*$//')" != "" ]; then | |
c=0 | |
re=$num | |
num=0 | |
while [ "$c" -lt "${#DS[*]}" ] | |
do | |
if echo "${DS[$c]}" | grep -q $re; then | |
num=$(($c+1)) | |
break | |
fi | |
((c=c+1)) | |
done | |
fi | |
if [ "$num" == 0 ]; then | |
echo "usage: csd <number greater than 0 | regular expression>" | |
return 1 | |
elif [ "$num" -gt "${#DS[*]}" ]; then | |
echo "$num is beyond the stack size." | |
return 1 | |
else | |
num=$((num-1)) | |
typeset dir="${DS[$num]}" | |
shiftStackUp $num | |
cd_ "$dir" | |
return $? | |
fi | |
} | |
alias cd=cd_ | |
function pa () | |
{ | |
local paths; | |
IFS=: read -ra paths <<< "$PATH"; | |
printf '%s\n' "${paths[@]}" | awk '!_[$0]++' | |
} | |
#THIS MUST BE AT THE END OF THE FILE FOR GVM TO WORK!!! | |
[[ -s "/Users/chuck/.gvm/bin/gvm-init.sh" ]] && source "/Users/chuck/.gvm/bin/gvm-init.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment