public
Last active

Colorize heroku production console for iTerm2 on OSX

  • Download Gist
heroku_colors.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
# iTerm2, OS X
# 1. change 'your_app_production' to your application name
# 1a. Tune the colors by your taste
# 2. put these functions to your .bashrc, .zshrc
# or anywhere where it gets loaded for your iTerm session
# 3. restart iTerm or 'source ~/.zshrc' and use these functions
 
set_color() {
local HEX_FG=$1
local HEX_BG=$2
local OPACITY=$3
 
local FG_R=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
local FG_G=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
local FG_B=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$3 * 257)}'`
local BG_R=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
local BG_G=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
local BG_B=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$3 * 257)}'`
 
arch -i386 /usr/bin/osascript <<EOF
tell application "iTerm"
tell current session of current terminal
set foreground color to {$FG_R, $FG_G, $FG_B}
set background color to {$BG_R, $BG_G, $BG_B}
set transparency to "$OPACITY"
end tell
end tell
EOF
}
 
reset_colors() {
set_color ffffff 000000 0
}
 
hpp() {
set_color ffffff 330000 0
heroku $@ --app your_app_production #change me
reset_colors
}
 
hps() {
set_color ffffff 002900 0
heroku $@ --app your_app_staging #change me
reset_colors
}
 
# must have remote heroku added
deploy_migrate_production() {
git push heroku && hpp rake db:migrate && hpp restart
}
 
deploy_migrate_production_with_maintenance() {
git push production && hpp maintenance:on && hpp run rake db:migrate && hpp restart && hpp maintenance:off
}
 
hrk(){
set_color ffffff 330000 0
heroku $@
reset_colors
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.