2017-02-18 18:05:08 +00:00
|
|
|
platform=`uname`
|
|
|
|
|
2013-07-07 21:30:11 +00:00
|
|
|
function activate_virtualenv() {
|
2016-05-04 15:27:31 +00:00
|
|
|
if [ -f venv/bin/activate ]; then . venv/bin/activate;
|
|
|
|
elif [ -f ../venv/bin/activate ]; then . ../venv/bin/activate;
|
|
|
|
elif [ -f ../../venv/bin/activate ]; then . ../../venv/bin/activate;
|
|
|
|
elif [ -f ../../../venv/bin/activate ]; then . ../../../venv/bin/activate;
|
2013-07-07 21:30:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-10-16 05:11:24 +00:00
|
|
|
function play {
|
|
|
|
# Skip DASH manifest for speed purposes. This might actually disable
|
|
|
|
# being able to specify things like 'bestaudio' as the requested format,
|
|
|
|
# but try anyway.
|
|
|
|
# Get the best audio that isn't WebM, because afplay doesn't support it.
|
|
|
|
# Use "$*" so that quoting the requested song isn't necessary.
|
|
|
|
youtube-dl --default-search=ytsearch: \
|
|
|
|
--youtube-skip-dash-manifest \
|
|
|
|
--output="${TMPDIR:-/tmp/}%(title)s-%(id)s.%(ext)s" \
|
|
|
|
--restrict-filenames \
|
|
|
|
--format="bestaudio[ext!=webm]" \
|
|
|
|
--exec=afplay "$*"
|
|
|
|
}
|
|
|
|
|
|
|
|
function mp3 {
|
|
|
|
# Get the best audio, convert it to MP3, and save it to the current
|
|
|
|
# directory.
|
|
|
|
youtube-dl --default-search=ytsearch: \
|
|
|
|
--restrict-filenames \
|
|
|
|
--format=bestaudio \
|
|
|
|
--extract-audio \
|
|
|
|
--format="bestaudio[ext!=webm]" \
|
|
|
|
--audio-quality=1 "$*" \
|
|
|
|
--exec=afplay "$*"
|
|
|
|
}
|
|
|
|
|
2013-07-07 21:25:47 +00:00
|
|
|
function git-new-remote-tracking {
|
|
|
|
git checkout -b $1 && git push -u origin $1
|
|
|
|
}
|
|
|
|
|
|
|
|
function git_branch_name {
|
|
|
|
val=`git branch 2>/dev/null | grep '^*' | colrm 1 2`
|
|
|
|
echo "$val"
|
|
|
|
}
|
|
|
|
|
|
|
|
function git-done {
|
|
|
|
branch=`git_branch_name`
|
|
|
|
git checkout master && git merge $branch --ff-only && bundle install && rake db:migrate db:test:prepare && rake && git push && git branch -D $branch && git push origin :$branch
|
|
|
|
}
|
|
|
|
|
|
|
|
function git-nuke {
|
2015-02-24 04:34:00 +00:00
|
|
|
git checkout master && git branch -D $1 && git push origin :$1
|
2013-07-07 21:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function git-on-master {
|
|
|
|
branch=`git_branch_name`
|
2013-07-10 16:13:13 +00:00
|
|
|
git checkout master && git pull --rebase
|
2013-07-07 21:25:47 +00:00
|
|
|
git checkout $branch
|
|
|
|
git rebase master
|
|
|
|
}
|
|
|
|
|
|
|
|
function take {
|
|
|
|
mkdir $1
|
|
|
|
cd $1
|
|
|
|
}
|
|
|
|
|
2013-07-08 11:22:06 +00:00
|
|
|
# Search google for a term
|
|
|
|
function google() {
|
2017-02-18 18:05:08 +00:00
|
|
|
if [[ $platform == 'Darwin' ]]; then
|
|
|
|
open /Applications/Google\ Chrome.app/ "http://www.google.com/search?q= $1";
|
|
|
|
else
|
2017-02-18 18:08:12 +00:00
|
|
|
chrome "http://www.google.com/search?q= $1";
|
2017-02-18 18:05:08 +00:00
|
|
|
fi
|
2013-07-08 11:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Open a file in chrome
|
|
|
|
function chrome () {
|
2017-02-18 18:05:08 +00:00
|
|
|
if [[ $platform == 'Darwin' ]]; then
|
|
|
|
open -a /Applications/Google\ Chrome.app/ "$1"
|
|
|
|
else
|
|
|
|
chrome "$1"
|
|
|
|
fi
|
2013-07-08 11:22:06 +00:00
|
|
|
}
|
2013-07-10 16:13:13 +00:00
|
|
|
|
|
|
|
# See top 10 bash commands
|
|
|
|
function hist() {
|
|
|
|
cat ~/.history|cut -d ';' -f 2- 2>/dev/null| awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
|
|
|
|
}
|