Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Runspec stuff
# User specific aliases and functions go here (override system defaults)
# Re-read stuff
alias init='source ~/.bashrc'
alias newalias='vi ~/.bash_aliases && init'
alias enwalias=newalias
alias hg='lh'
alias grep='grep --color' # shows matches in color
alias Less=less
alias ls='ls -aF -G' # List files with symbols (/ * @) and colors
alias ll='ls -alF -G' # List files including hidden files, with symbols
alias mv='mv -i' # Interactive confirmation before move
alias rm='rm -i' # Interactive confirmation before delete
alias cp='cp -ip' # Interactive confirm. before copy; preserve timestamp
alias ..='cd ..' # go up
alias cd..='cd ..' # go up
alias ...='cd ../..' # go up two
alias got='git'
alias gitdiff='git diff'
alias pse='ps -ef | grep -v grep | grep -i'
alias cdd='cd ~/dev/spaceman'
alias no='git diff master --name-only'
alias last='git diff HEAD^-1'
alias fml='git commit -a -m "Applied lint/rubocop fixes"'
alias hack='git commit -a -m "Hacking"'
alias hacking=hack
alias tweak='git commit -a -m "Code review tweaks"'
alias local_ngrok='ngrok http -subdomain=davidp 5000'
alias sso='HEROKU_ORGANIZATION=wework heroku login --sso'
alias get-aws-credentials='f(){ cmd="docker run -it --rm -v ~/.aws:/package/.aws quay.io/wework/onelogin-aws-saml sh -c \"python /package/samlapi.py "$@"\""; bash -c "${cmd}" unset -f f; }; f'
alias docker-bash='docker-compose run --rm base bash'
portkill() { lsof | awk "/TCP \*:$1/ {print \$2}" | xargs -r -l kill $2; }
alias gut=git
alias kilall=killall
alias rpsec=rspec
cdj() {
if pwd | grep -q spec; then
if pwd | grep -q spec.lib; then
# Convert spec/lib/foo to lib/foo
cd ${PWD/spec/}
else
# Convert spec/foo to app/foo
cd ${PWD/spec/app}
fi
elif pwd | grep -q lib; then
# Convert lib to spec/lib
cd ${PWD/lib/spec\/lib}
else
cd ${PWD/app/spec}
fi
}
alias jt=cdj
lh() {
history | grep -i "$1" | grep -v hg | grep -v history | grep -v '[0-9] lh' | tail -n ${2-5}
}
myfgrep() {
echo "Searching for '$2' in '$1'"
find . -type f -name "$1" -exec grep -H -i --color $3 "$2" {} \;
}
alias mygrep=myfgrep
alias cs='ag'
csx() {
if [[ $# == 1 ]]; then
myfgrep "*" "$1"
else
# Same as regular (files, target)
myfgrep $*
fi
}
cdf() {
cd `dirname $1`
}
mybasedir() {
echo $PWD | sed 's/\(dev\/[^/]*\).*$/\1/'
}
alias cdg='cd `mybasedir`'
runspec() {
there=$PWD
pushd `mybasedir`
rootdir=$PWD
specs=""
args=""
for afile in $*; do
if [[ $afile != *.rb* ]]; then
args="$args $afile"
else
# if "afile" starts with "spec", use rootdir
if [[ $afile == spec/* ]]; then
specs="$specs $rootdir/$afile"
else
specs="$specs $there/$afile"
fi
fi
done
echo ITYM:
#echo RUBYOPT=\"-W0\" bundle exec rspec $specs $args
echo bundle exec rspec $specs $args
#export RUBYOPT="-W0"
time bundle exec rspec $specs $args
rspec_result=$?
status="PASS"
if [[ $rspec_result != 0 ]]; then
status="FAIL"
fi
message="Test result: $status for $*"
terminal-notifier -message "$message"
popd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.