Skip to content

Instantly share code, notes, and snippets.

@stringsn88keys
Last active October 20, 2021 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringsn88keys/9793788 to your computer and use it in GitHub Desktop.
Save stringsn88keys/9793788 to your computer and use it in GitHub Desktop.
A section of my .zlogin to notify me when a process > 4 minutes finishes. (Mac-specific)
export PMPSVN='http://cvs.appriss.com/svn/softeng/projects/pmp'
export PATH=~/bin:$PATH
export DYLD_LIBRARY_PATH=~/instantclient_11_2
#alias gvim='mvim'
export EDITOR=/usr/local/bin/mvim
export NARWHAL_ENGINE=jsc
export RSENSE_HOME=~/.vim/bundle/rsense
export PATH="/Library/PostgreSQL/9.2/bin:/usr/local/narwhal/bin:$PATH"
#export CAPP_BUILD="/Users/tpowell/Build"
alias ll='ls -l'
alias mkdirtree='mkdir -p'
alias ber='bundle exec rake'
alias cukes='bundle exec cucumber'
#alias specs='bundle exec rspec'
function specs() {
bundle exec rake spec $*
}
#alias specs='bundle exec rake spec SPEC_OPTS='
alias bec='bundle exec cap'
#export PMP_FARM_DB_USER=pmp_farm
export JAVA_HOME=`/usr/libexec/java_home`
# Setting PATH for JRuby 1.6.7.2
# The orginal version is saved in .bash_login.jrubysave
PATH="${PATH}:/Library/Frameworks/JRuby.framework/Versions/Current/bin"
export PATH
# http://fendrich.se/blog/2012/09/28/no/
alias -g L="|less"
alias -g TL='|tail -20'
alias -g NUL=">/dev/null 2>&1"
alias -g GR="gitroot"
# hash -d must be accessed via ~aliasname
hash -d bin=~/bin
hash -d projects=~/projects
hash -d dbproj=~/Dropbox/projects
hash -d dbprog=~/Dropbox/programming
hash -d gsd=~/Dropbox/projects/gsd-manager/gsd
# http://tldp.org/HOWTO/Xterm-Title-4.html
# http://www.nparikh.org/unix/prompt.php#zsh
# case $TERM in
# xterm*)
# precmd () {print -Pn "\e]0;%n@%m: %~\a"}
# ;;
# esac
# http://blog.bstpierre.org/zsh-prompt
# function title() {
# # escape '%' chars in $1, make nonprintables visible
# local a=${(V)1//\%/\%\%}
#
# # Truncate command, and join lines.
# a=$(print -Pn "%40>...>$a" | tr -d "\n")
# case $TERM in
# screen*)
# print -Pn "\e]2;$a @ $2\a" # plain xterm title
# print -Pn "\ek$a\e\\" # screen title (in ^A")
# print -Pn "\e_$2 \e\\" # screen location
# ;;
# xterm*)
# print -Pn "\e]2;$a @ $2\a" # plain xterm title
# ;;
# esac
# }
#
# # precmd is called just before the prompt is printed
# function precmd() {
# # title "zsh" "%m:%55<...<%~"
# }
#
# function tab_title() {
# echo "$1"
# }
#
# # preexec is called just before any command line is executed
# function preexec() {
# set_title_tab "$(tab_title)"
# # title "{$tab_title}" "%m:%35<...<%~"
# }
function get_load() {
uptime | awk '/days?/{print $11} !/days?/{print $9}' | tr ',' ' '
}
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
echo '%(!.!.➜)'
}
PROMPT='%{$fg_bold[green]%}%~ %{$fg_bold[blue]%}$(git_prompt_info) %{$fg[red]%}$(prompt_char) % %{$reset_color%}'
RPROMPT='%{$fg_bold[red]%}[$(get_load)] %{$fg_bold[green]%}%*%{$reset_color%}'
alias gitroot='cd $(git rev-parse --show-toplevel)'
alias mygitroot='echo $(git rev-parse --show-toplevel)'
function csbld {
find . -name '*.rb' > $(mygitroot)/cscope.out
find . -name '*.erb' >> $(mygitroot)/cscope.out
find . -name '*.js' >> $(mygitroot)/cscope.out
}
alias reload='exec /bin/zsh -l'
bindkey -v
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
eval "$(rbenv init -)"
#doge
# http://www.reddit.com/r/linux/comments/1pooe6/zsh_tip_notify_after_long_processes/
function notify_preexec() {
# Note the date when the command started, in unix time.
CMD_START_DATE=$(date +%s)
# Store the command that we're running.
CMD_NAME="$1"
}
function notify_precmd() {
# Proceed only if we've ran a command in the current shell.
if ! [[ -z $CMD_START_DATE ]]; then
# Note current date in unix time
CMD_END_DATE=$(date +%s)
# Store the difference between the last command start date vs. current date.
CMD_ELAPSED_TIME=$(($CMD_END_DATE - $CMD_START_DATE))
# Store an arbitrary threshold, in seconds.
CMD_NOTIFY_THRESHOLD=240
if [[ $CMD_ELAPSED_TIME -gt $CMD_NOTIFY_THRESHOLD ]]; then
# Beep or visual bell if the elapsed time (in seconds) is greater than threshold
# Send a notification
if [[ "$CMD_NAME" =~ 'rake' ]]; then
say "$CMD_NAME FINISHED IN $CMD_ELAPSED_TIME SECONDS"
fi
unset CMD_NAME
unset CMD_START_DATE
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment