Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 156 lines (122 sloc) 3.816 kB
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
1 function timer_start {
2 timer=${timer:-$SECONDS}
3 }
4
5 function timer_stop {
6 timer_show=$(($SECONDS - $timer))
7 unset timer
8 }
9
10 trap 'timer_start' DEBUG
11
4ce773a @jyurek Added bash config
authored
12 function parse_git_dirty {
13 [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo ''
14 }
15
16 function parse_git_branch {
1391652 @jyurek Various and sundry.
authored
17 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
4ce773a @jyurek Added bash config
authored
18 }
19
a0fdae7 @jyurek Added hgrc
authored
20 function parse_hg_branch {
21 hg branch 2>/dev/null
22 }
23
4ce773a @jyurek Added bash config
authored
24 function latest_command {
25 history | tail -n 1 | sed 's/[0-9 ]*\(.*\)/\1/'
26 }
27
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
28 function sticky_if_frontmost {
29 iterm_is_frontmost_application=$(osascript -e 'tell application "iTerm" to get frontmost')
30 frontmost_in_iterm=$(osascript -e 'tell application "iTerm" to tell the current terminal to tell the current session to get id')
31 this_terminal=`tty`
32
33 sticky_flag="-s"
34 if [[ $iterm_is_frontmost_application == "true" ]]; then
35 if [[ $frontmost_in_iterm == $this_terminal ]]; then
36 sticky_flag=
37 fi
38 fi
39 }
40
4ce773a @jyurek Added bash config
authored
41 function growl_latest_command {
4898778 @jyurek Growl should make a sticky, high priority alert when there is a non-z…
authored
42 priority="Normal"
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
43 if [[ $1 != 0 ]]; then
73b2eda @jyurek Different Growl notifications for exitcode == 0 and != 0
authored
44 priority="Emergency"
4898778 @jyurek Growl should make a sticky, high priority alert when there is a non-z…
authored
45 fi
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
46
47 sticky_if_frontmost
48 latest_command | growlnotify $sticky_flag -p $priority -n "Command Prompt $priority" `pwd` 1>/dev/null 2>&1
4ce773a @jyurek Added bash config
authored
49 }
50
51 function prompt_command_function
52 {
4898778 @jyurek Growl should make a sticky, high priority alert when there is a non-z…
authored
53 last_result=$?
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
54 timer_stop
55 # growl_latest_command $last_result
4ce773a @jyurek Added bash config
authored
56
4898778 @jyurek Growl should make a sticky, high priority alert when there is a non-z…
authored
57 last_result="\[\e[33m\]$last_result\[\e[0m\]"
58 titlebar_last_command="\[\e]2;$(latest_command)\a\]"
4ce773a @jyurek Added bash config
authored
59
60 git_branch=$(parse_git_branch)
a0fdae7 @jyurek Added hgrc
authored
61 hg_branch=$(parse_hg_branch)
4ce773a @jyurek Added bash config
authored
62 git_dirty= #$(parse_git_dirty)
a0fdae7 @jyurek Added hgrc
authored
63 hg_dirty=
4ce773a @jyurek Added bash config
authored
64
65 git_dirty=${git_dirty:+" \[\e[31m\]$git_dirty\[\e[0m\]"}
66 git_branch=${git_branch:+" (\[\e[35m\]${git_branch}\[\e[0m\]${git_dirty})"}
a0fdae7 @jyurek Added hgrc
authored
67 hg_branch=${hg_branch:+" (\[\e[36m\]${hg_branch}\[\e[0m\]${hg_dirty})"}
4ce773a @jyurek Added bash config
authored
68
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
69 current_ruby=$(basename ${RUBY_ROOT:-none})
70
71 PS1="$titlebar_last_command$last_result [\[\e[32m\]${timer_show}s\[\e[0m\]] \h:\[\e[32m\]\w\[\e[0m\] \e[33m$current_ruby\e[0m \u$git_branch$hg_branch\$ "
4ce773a @jyurek Added bash config
authored
72 }
73
74 function gemcd {
75 cd `dirname \`gem which $1\``
76 }
77
1391652 @jyurek Various and sundry.
authored
78 function ghistory
79 {
80 git grep $1 $(git rev-list --all)
81 }
82
4ce773a @jyurek Added bash config
authored
83 export PROMPT_COMMAND=prompt_command_function
84
ac895ef @jyurek Removed old stuff from bashrc, made brew location more flexible
authored
85 export BREW=/usr/local/bin/brew
469bc5b @jyurek homebrew env tweaks
authored
86 export BREW_HOME=`$BREW --prefix`
87 export PATH=$BREW_HOME/bin:$BREW_HOME/sbin:$HOME:$PATH:$HOME/bin:/usr/local/share/python
4ce773a @jyurek Added bash config
authored
88 export EDITOR=/usr/bin/vim
89
90 export CDPATH=.:~:~/Development
91 alias ...='cd ../..'
92 alias ....='cd ../../..'
93 alias .....='cd ../../../..'
94
e603a90 @jyurek vimmy shell exit
authored
95 alias :q="exit"
1391652 @jyurek Various and sundry.
authored
96 alias psg="ps aux | grep"
e603a90 @jyurek vimmy shell exit
authored
97
4ce773a @jyurek Added bash config
authored
98 alias rerc='source ~/.bash_profile'
8b0a5d4 @jyurek Alias mvim to open new files in the same window, but new tab.
authored
99 alias mvim='mvim --servername VIM --remote-tab-silent'
9c0b53a @jyurek Aliases and dark solarized colors
authored
100 alias be='bundle exec'
101
1391652 @jyurek Various and sundry.
authored
102 alias remigrate='rake db:migrate && rake db:migrate:redo && rake db:schema:dump db:test:prepare'
103
104 alias dnsip='dig myip.opendns.com @resolver1.opendns.com +short'
105
9c0b53a @jyurek Aliases and dark solarized colors
authored
106 ssh-agent
107 ssh-add
4ce773a @jyurek Added bash config
authored
108
60664a7 @jyurek Removed and put in AWS account switching
authored
109 export AWS_ACCOUNT=jyurek
979c47d @jyurek Add a switching function for EY like the one for AWS
authored
110 function aws_account {
60664a7 @jyurek Removed and put in AWS account switching
authored
111 if [ -f $HOME/.aws/$1 ]; then
112 source $HOME/.aws/$1
113 export AWS_ACCOUNT=$1
114 else
115 echo "No AWS Credentials for $1"
116 fi
117 }
979c47d @jyurek Add a switching function for EY like the one for AWS
authored
118 aws_account $AWS_ACCOUNT
119
120 export EY_ACCOUNT=thoughtbot
121 function ey_account {
122 if [ -f $HOME/.ey/$1 ]; then
123 ln -sf $HOME/.ey/$1 $HOME/.eyrc
124 export EY_ACCOUNT=$1
125 else
126 echo "No EY Credentials for $1"
127 fi
128 }
129 ey_account $EY_ACCOUNT
60664a7 @jyurek Removed and put in AWS account switching
authored
130
b486eec @jyurek Some tweaks
authored
131 export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
132 export EC2_AMITOOL_HOME="/usr/local/Cellar/ec2-ami-tools/1.3-45758/jars"
133 export EC2_HOME="/usr/local/Cellar/ec2-api-tools/1.3-62308/jars"
134
469bc5b @jyurek homebrew env tweaks
authored
135 if [ -f $BREW_HOME/etc/bash_completion ]; then
136 . $BREW_HOME/etc/bash_completion
4ce773a @jyurek Added bash config
authored
137 fi
138
469bc5b @jyurek homebrew env tweaks
authored
139 if [ -f $BREW_HOME/etc/bash_completion.d/git-completion.bash ]; then
140 . $BREW_HOME/etc/bash_completion.d/git-completion.bash
4ce773a @jyurek Added bash config
authored
141 fi
142
1391652 @jyurek Various and sundry.
authored
143 function g {
144 if [[ $# > 0 ]]; then
145 git $@
146 else
147 git st
148 fi
149 }
150
5f7b640 @jyurek Modify prompt. Drop rvm for chruby.
authored
151 # Use chruby instead of rvm
152 export RBXOPT=-X19
153 . /usr/local/opt/chruby/share/chruby/chruby.sh
154 export RUBIES=(/usr/local/ruby/*)
155 chruby 1.9.3
Something went wrong with that request. Please try again.