Last active
November 1, 2022 19:32
-
-
Save Magnacarter/2874a109299ee38a43de to your computer and use it in GitHub Desktop.
Bash profile with great shortcuts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/.profile | |
# ------------------------------------------------------------ | |
# Set paths | |
# ------------------------------------------------------------ | |
export PATH="/usr/local/bin:$PATH" | |
export PATH="$PATH:$HOME/.composer/vendor/bin" | |
export PATH=~/.npm-global/bin:$PATH | |
# ------------------------------------------------------------ | |
# Add color to the terminal | |
# ------------------------------------------------------------ | |
export CLICOLOR=1 | |
export LSCOLORS=GxFxCxDxBxegedabagaced | |
# ------------------------------------------------------------ | |
# Set default file editor | |
# ------------------------------------------------------------ | |
export EDITOR=/usr/bin/nano | |
# ------------------------------------------------------------ | |
# Set generic shortcuts | |
# ------------------------------------------------------------ | |
alias c="clear" | |
alias ll="ls -FGlAhp" | |
alias ip="curl icanhazip.com" | |
alias sbp="source ~/.bash_profile" | |
alias showfiles="defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app" | |
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app" | |
# ------------------------------------------------------------ | |
# Set application shortcuts | |
# ------------------------------------------------------------ | |
alias 1pw="open -a 1Password\ 5" | |
alias chrome="open -a Google\ Chrome" | |
alias hipchat="open -a HipChat" | |
alias mail="open -a Mail" | |
alias photoshop="open -a Adobe\ Photoshop\ CS5" | |
alias sequelpro="open -a Sequel\ Pro" | |
alias slack="open -a Slack" | |
alias spotify="open -a Spotify" | |
alias sublime="open -a Sublime\ Text" | |
# ------------------------------------------------------------ | |
# Set vagrant shortcuts | |
# ------------------------------------------------------------ | |
alias v="vagrant up" | |
alias vh="vagrant halt" | |
alias vr="vagrant reload" | |
alias vp="vagrant up --provision" | |
# ------------------------------------------------------------ | |
# Set WP-CLI shortcuts | |
# ------------------------------------------------------------ | |
alias wpv="wp core version" | |
# ------------------------------------------------------------ | |
# Set git shortcuts | |
# ------------------------------------------------------------ | |
alias gp="git pull" | |
alias gs="git status" | |
alias gu="git add -u" | |
alias ga="git add -A" | |
alias gd="git diff" | |
alias gc="git commit -m" | |
git () { | |
if [[ $@ == "-v" ]]; then | |
command git --version | more | |
elif [[ $@ == "release log" ]]; then | |
echo "***** Contributors from master...develop *****" && command git shortlog -sn master...develop && echo "***** Merged Pull Requests from master...develop *****" && git log master...develop | grep "Merge pull request" | more | |
else | |
command git "$@" | |
fi | |
} | |
# ------------------------------------------------------------ | |
# Set dev-lib shortcut | |
# ------------------------------------------------------------ | |
svn-push () { | |
command dev-lib/svn-push "$@" | |
} | |
# ------------------------------------------------------------ | |
# Source vassh | |
# ------------------------------------------------------------ | |
if [ -f ~/code/vassh/vassh.sh ]; then | |
source ~/code/vassh/vassh.sh | |
fi | |
# ------------------------------------------------------------ | |
# Source WP-CLI completion | |
# ------------------------------------------------------------ | |
if [ -f ~/.wp-cli/wp-completion.bash ]; then | |
source ~/.wp-cli/wp-completion.bash | |
fi | |
# ------------------------------------------------------------ | |
# Source autoenv | |
# ------------------------------------------------------------ | |
if [ -f /usr/local/opt/autoenv/activate.sh ]; then | |
source /usr/local/opt/autoenv/activate.sh | |
fi | |
# ------------------------------------------------------------ | |
# Extract most known archives with a single 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 | |
} | |
# ------------------------------------------------------------ | |
# Open a URL in Chrome | |
# ------------------------------------------------------------ | |
url () { | |
chrome "http://$*" | |
} | |
# ------------------------------------------------------------ | |
# Google it, bro | |
# ------------------------------------------------------------ | |
google () { | |
open "https://google.com/search?q=$*" | |
} | |
# ------------------------------------------------------------ | |
# Search for a file using MacOS Spotlight's metadata | |
# ------------------------------------------------------------ | |
spotlight () { | |
mdfind "kMDItemDisplayName == '$@'wc" | |
} | |
# ------------------------------------------------------------ | |
# Moves a file to the MacOS trash | |
# ------------------------------------------------------------ | |
trash () { | |
command mv "$@" ~/.Trash | |
} | |
# ------------------------------------------------------------ | |
# Set git auto-completion | |
# | |
# https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion | |
# ------------------------------------------------------------ | |
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then | |
. `brew --prefix`/etc/bash_completion.d/git-completion.bash | |
fi | |
# ------------------------------------------------------------ | |
# Set git PS1 integration | |
# | |
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh | |
# ------------------------------------------------------------ | |
if [ -f ~/.git-prompt.sh ]; then | |
source ~/.git-prompt.sh | |
export PS1='\[\033[32m\]\u@\h\[\033[00m\][$(date "+%H:%M:%S")]:\[\033[35m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\n$ ' | |
GIT_PS1_SHOWDIRTYSTATE=true | |
fi | |
# Setting PATH for Python 3.6 | |
# The original version is saved in .bash_profile.pysave | |
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" | |
export PATH | |
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment