Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
My macOS bash profile, strung together from various tips and tricks and failings
# OS X Specific
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
## Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
## Brew Wrap - Used for Brew file syncing
if [ -f $(brew --prefix)/etc/brew-wrap ]; then
source $(brew --prefix)/etc/brew-wrap
fi
export HOMEBREW_FILE_APPSTORE=0
# Bash Completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
## OS X Default Settings
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true # Disable metadata on network vols
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true # Disable metadata on USB vols
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true # Enable AirDrop on all Macs
## Homebrew
export HOMEBREW_CASK_OPTS='--appdir=/Applications'
### Brew Bash Completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
## OS X Aliases
alias brewup='brew update && brew upgrade && brew prune'
alias flush='sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches'
alias backuppi="rsync -aHv --delete-during --exclude-from=/Users/chase/bin/pibackup-exclude.txt -e 'ssh -p 22' pi@192.168.0.6:/ ~/Documents/Backups/pibackup/"
alias f='open -a Finder ./'
alias apt-get='brew'
alias ax='chmod a+x'
alias finderhide='defaults write com.apple.finder AppleShowAllFiles NO'
alias finderunhide='defaults write com.apple.finder AppleShowAllFiles YES'
alias hide='chflags hidden'
alias show='chflags nohidden'
function findpath () {
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}
## Terminal Colors
export CLICOLOR=1
export PS1="\[\033[38;5;6m\]\u\[$(tput sgr0)\]\[\033[38;5;7m\]@\[$(tput sgr0)\]\[\033[38;5;15m\]\h\[$(tput sgr0)\]\[\033[38;5;7m\]:\[$(tput sgr0)\]\[\033[38;5;2m\][\w]\[$(tput sgr0)\]\[\033[38;5;7m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
## OS X Paths
export PATH=/usr/local/bin:$PATH
export PATH=/Users/chase/bin:$PATH
launchctl setenv PATH '/usr/local/bin:$PATH'
## Fix the shitty OS X Open With menu duplicates
function fixopenwith() {
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user
killall Finder
echo 'Open With has been rebuilt, Finder will relaunch'
}
################################
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
# Aliases
alias yt="youtube-dl -o '%(autonumber)02d-%(title)s.%(ext)s' --add-metadata"
alias c='clear'
alias ll="ls -la ${colorflag}"
alias apup="sudo service apache2 restart"
alias plexup="sudo service plexmediaserver restart"
alias ubup="sudo /etc/init.d/ubooquity restart"
alias install="sudo apt-get install"
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
# Default Settings
alias df='df -H'
alias du='du -ch'
alias ls='ls -la'
alias tar="tar xzvf"
# IP addresses
# http://brettterpstra.com/2013/03/31/a-few-more-of-my-favorite-shell-aliases/
alias ip='curl icanhazip.com'
alias localip='ipconfig getifaddr en1'
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
# Create a new directory and enter it
function md() {
mkdir -p "$@" && cd "$@"
}
# Search History with Up and Down
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
export PATH="/usr/local/sbin:$PATH"
# Dumb Typos
alias cd..='cd ..'
alias chomd='chmod'
alias sl='ls'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment