Skip to content

Instantly share code, notes, and snippets.

@enricodeleo
Last active December 4, 2015 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricodeleo/dc9868b64892a4485b47 to your computer and use it in GitHub Desktop.
Save enricodeleo/dc9868b64892a4485b47 to your computer and use it in GitHub Desktop.
Bash Profile OS X
# Brew bash complation (brew install bash-completion)
# you must install brew http://brew.sh/
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Brew's NVM (brew install nvm)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
# Git aware bash
# you must install with: brew install bash-git-prompt
if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh"
fi
# z - jump around
# brew install z
. $(brew --prefix)/etc/profile.d/z.sh
# go back x directories
b() {
str=""
count=0
while [ "$count" -lt "$1" ];
do
str=$str"../"
let count=count+1
done
cd $str
}
# External IP address
myip () {
echo
echo "Your public IP: ${underline}"
curl -s ip.appspot.com
echo "${reset}"
}
# Current active local ip addresses
ip () {
echo
echo "Your local IP(s): ${underline}"
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
echo "${reset}"
}
# Pretty Git Log
alias gitlog="git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# Recursively clean all .DS_Store on OSX
alias cleands="find . -type f -name '*.DS_Store' -ls -delete"
# manuals in preview
# example usage: pman nano
pman() {
man -t "${1}" | open -f -a /Applications/Preview.app/
}
# Sublime Text from shell
alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'
# Random commit
randc() {
git commit -m"`curl -s http://whatthecommit.com/index.txt`"
}
# Colors in terminal
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# ll is very useful
alias ll='ls -FGlAhp'
# Make dir and jump into it
mcd () { mkdir -p "$1" && cd "$1"; }
# Move file(s) to trash on OSX
trash () { command mv "$@" ~/.Trash ; }
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Php 5.6
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
# Paths required by brew
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/sbin:$PATH
# Android SDK
# must install with brew: brew install android-sdk
export ANDROID_HOME=/usr/local/opt/android-sdk
# Random password on the fly
# usage: randpass [INT] [-c]
randpass () {
if [[ "$1" != "" ]]; then
passlength="$1"
else
passlength=8
fi
if [[ "$2" == "-c" ]]; then
complexity="MIXEDCASEALPHANUMERIC"
else
complexity="LOWERCASEALPHANUMERIC"
fi
echo
echo "Your new password!${green}"
curl --request GET "https://passwd.me/api/1.0/get_password.txt?type=random&length=$passlength&charset=$complexity"
echo "${reset}"
echo
}
# Create a ZIP archive of a directory
# usage: zipdir directory
zipdir () { zip -r "$1".zip "$1" ; }
# Launch Chrome without web security for dev purposes
alias chromedev='open -a Google\ Chrome --args --disable-web-security'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment