1212# cd $brainstormr
1313#
1414# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr
15- #
1615
1716autoload edit-command-line
1817zle -N edit-command-line
1918bindkey ' ^Xe' edit-command-line
2019
20+ function ssh-ec2 {
21+ ssh ec2-user@$( aws ec2 describe-instances --filters Name=tag:Name,Values=$1 | jq -r ' .Reservations[].Instances[]|select(.State.Code == 16)|.PublicDnsName' | head -1)
22+ }
23+
24+ function pretty-json {
25+ ruby -e " require 'json'; puts (JSON.pretty_generate JSON.parse(STDIN.read))"
26+ }
27+
28+ function get-city() {
29+ if [ $1 = ' Maison-Neuve' ]; then
30+ echo " zmw:00000.27.07570"
31+ else
32+ echo $1
33+ fi
34+ }
35+
36+ function current-temp() {
37+ api_key=$( cat ~ /.wunderground)
38+ city=$( get-city $@ )
39+ curl -s " http://api.wunderground.com/api/${api_key} /geolookup/conditions/q/FR/${city} .json" | jq -r ' .current_observation | .feelslike_string'
40+ }
41+
42+ function hourly-temp() {
43+ api_key=$( cat ~ /.wunderground)
44+ city=$( get-city $@ )
45+ curl -s " http://api.wunderground.com/api/${api_key} /hourly/q/FR/${city} .json" | jq -r ' .hourly_forecast[] | "\(.FCTTIME.hour):\(.FCTTIME.min) - \(.feelslike.metric)C \(.feelslike.english)F"'
46+ }
47+
48+
49+ function now() {
50+ echo $( date " +%Y-%m-%d %H:%M:%S" ) - " $@ " >> ./.now
51+ }
52+
2153function ssht() {
2254 set_title $@
2355 ssh -t gw ssh -At $@
@@ -103,7 +135,7 @@ function cur() {
103135
104136function git_author_info() {
105137 ref=$( git symbolic-ref HEAD 2> /dev/null) || return
106- echo " Current author: $( git config user.name) "
138+ echo " Current author: $( git config user.name) < $( git config user.email ) > "
107139}
108140
109141function ruby-version-name() {
@@ -117,22 +149,55 @@ function dir_jump() {
117149 git_author_info
118150}
119151
120- function r3() {
121- BUNDLE_GEMFILE=Gemfile.rails3 $@
122- }
123-
124152function rmb() {
125153 (git branch -D $@ || test 1) && git push origin :$@
126154}
127155
156+ function hg() {
157+ history | grep " $@ "
158+ }
159+
160+ function _get_workspace_status() {
161+ aws ec2 describe-instances --filters " Name=tag:Name,Values=eirik-workspace"
162+ }
163+
164+ function ws_status() {
165+ full_status=$( _get_workspace_status)
166+ echo $full_status | jq -r ' .Reservations[0].Instances[0].State.Name'
167+ }
168+
169+ function _get_status_code() {
170+ full_status=$( _get_workspace_status)
171+ echo $full_status | jq -r ' .Reservations[0].Instances[0].State.Code'
172+ }
173+
174+ function ws_login {
175+ status_code=$( _get_status_code)
176+ if [ $status_code -gt 16 ]
177+ then
178+ echo " starting workspace"
179+ aws ec2 start-instances --instance-ids=$( echo $full_status | jq -r ' .Reservations[0].Instances[0].InstanceId' )
180+ else
181+ ssh $( echo $full_status | jq -r ' .Reservations[0].Instances[0].PublicDnsName' )
182+ fi
183+ }
184+
185+ function ws_stop {
186+ status_code=$( _get_status_code)
187+ if [ $status_code -eq 16 ]
188+ then
189+ echo " stopping workspace"
190+ aws ec2 stop-instances --instance-ids=$( echo $full_status | jq -r ' .Reservations[0].Instances[0].InstanceId' )
191+ else
192+ echo $full_status | jq -r ' .Reservations[0].Instances[0].State.Name'
193+ fi
194+ }
195+
128196export BUNDLER_EDITOR=' mvim'
129- export EDITOR=' mvim'
197+ export EDITOR=' mvim -f '
130198
131- alias console= ' open -a Console '
199+ alias dcm= ' docker-compose '
132200alias gem_tunnel=' ssh -NCf -L 2000:localhost:80 "ubuntu@gems.efficiency20.com"'
133- alias cuc=' cucumber'
134- alias br=' bundle exec rspec'
135- alias rs=' rake spec'
136201alias gt=' git stash'
137202alias ghco=' git-hub-commit $1'
138203alias glc=" git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit"
@@ -141,3 +206,4 @@ alias gw='git checkout $1 && git rebase master'
141206alias fix=' git diff --name-only | uniq | xargs $EDITOR'
142207alias tmux=" TERM=screen-256color-bce tmux"
143208alias gpair=' dir_jump /Users/esinclair/github/edsinclair/git-pair'
209+ alias tt=' timetrap'
0 commit comments