Skip to content

Instantly share code, notes, and snippets.

@bbatsche
Created November 19, 2015 18:05
Show Gist options
  • Save bbatsche/1689697f4e8b4e3ec5f5 to your computer and use it in GitHub Desktop.
Save bbatsche/1689697f4e8b4e3ec5f5 to your computer and use it in GitHub Desktop.
extendedPWD() {
pwd_length=25
((pwd_length2=$pwd_length + 2))
((pwd_length3=$pwd_length - 2))
DIR=`pwd`
echo $DIR | grep "^$HOME" >> /dev/null
if [ $? -eq 0 ]; then
CURRDIR=`echo $DIR | awk -F$HOME '{print $2}'`
newPWD="~$CURRDIR"
if [ $(echo -n $newPWD | wc -c | tr -d " ") -gt $pwd_length2 ]; then
newPWD="~/..$(echo -n $PWD | sed -e "s/.*\(.\{$pwd_length3\}\)/\1/")"
fi
elif [ "$DIR" = "$HOME" ]; then
newPWD="~"
elif [ $(echo -n $PWD | wc -c | tr -d " ") -gt $pwd_length2 ]; then
newPWD="..$(echo -n $PWD | sed -e "s/.*\(.\{$pwd_length\}\)/\1/")"
else
newPWD="$(echo -n $PWD)"
fi
}
export PROMPT_COMMAND="extendedPWD; $PROMPT_COMMAND"
PS1='(\@) [\[\e[1;32;4m\]\h\[\e[m\]:\[\e[0;36m\]$newPWD\[\e[m\]] \[\e[0;32m\]\u\[\e[m\]\$ '
alias ll='ls -GFlh'
alias la='ls -GFAlh'
alias spot='mdfind -onlyin `pwd`'
alias px='ps -xco pid,pcpu,pmem,command'
alias pxa='ps -Aco user,pid,pcpu,pmem,command'
export PATH="~/bin"
export PATH="$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin"
export PATH="$PATH:/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands"
export PATH="$PATH:/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources"
export PATH="$PATH:/usr/X11R6/include:"
export PATH="$PATH:/Developer/Tools"
export PATH="$PATH:$HOME/Applications/TextMate.app/Contents/Resources"
export PATH="$PATH:/System/Library/ServerSetup"
export PATH="$PATH:/usr/local/mysql/bin"
export PATH="$PATH:/bin:/sbin"
export PATH="$PATH:."
export GEM_PATH="$HOME/.gem/ruby/1.8:/Library/Ruby/Gems/1.8"
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home"
export VISUAL="mate"
export HISTCONTROL=erasedups
export HISTSIZE=10000
export HISTFILESIZE=10000
shopt -s histappend
export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
bind '"\t":menu-complete'
shopt -s checkwinsize
source /Users/bbatsche/.iterm2_shell_integration.bash
set meta-flag on
set input-meta on
set output-meta on
set convert-meta off
set completion-ignore-case off
set editing-mode vi
"\e[B": history-search-forward
"\e[A": history-search-backward
$if Bash
Space: magic-space
$endif
# $include /etc/inputrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment