Last active
February 24, 2017 21:10
-
-
Save djchie/52cbdf61aea20cffbef15019f4e35fb3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH | |
| export EDITOR='subl -w' | |
| # Aliases | |
| # Meta aliases | |
| # Opens bash profile | |
| alias bprof="subl -n ~/.bash_profile" | |
| # Refreshes bash profile | |
| alias rbprof="source ~/.bash_profile" | |
| # Opens psqlrc for postgresql | |
| alias psqlrc="subl -n ~/.psqlrc" | |
| # Opens hosts file | |
| alias hosts="subl -n /etc/hosts" | |
| # System aliases | |
| # Actually clear the terminal and all of the text | |
| alias clear="clear && printf '\e[3J'" | |
| # Counts the number of non-hidden files in the current directory | |
| alias countFiles="echo $(ls -1 | wc -l)" | |
| # Shows all hidden files in finder | |
| alias showHiddenFiles="defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app" | |
| # Hides all hidden files in finder | |
| alias hideHiddenFiles="defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app" | |
| # Locks your Mac | |
| alias lockscreen="/System/Library/CoreServices/\"Menu Extras\"/User.menu/Contents/Resources/CGSession -suspend" | |
| # Copies your public key to the clipboard | |
| alias public-key="cat ~/.ssh/id_rsa.pub | pbcopy" | |
| # Navigational aliases | |
| # Sets home as cd | |
| alias home="cd" | |
| # Sets desktop as cd ~/Desktop | |
| alias desktop="cd ~/Desktop" | |
| # Sets documents as cd ~/Documents | |
| alias documents="cd ~/Documents" | |
| # Sets development as cd ~/Development | |
| alias development="cd ~/Development" | |
| # Sets sandbox as cd ~/Development/sandbox | |
| alias sandbox="cd ~/Development/sandbox" | |
| # Sets instore as cd ~/Development/instore | |
| alias instore="cd ~/Development/instore" | |
| # Sets instore-server as cd ~/Development/instore/instore-server | |
| alias instore-server="cd ~/Development/instore/instore-server" | |
| # Sets ggproductions2010 as cd ~/Development/ggproductions2010 | |
| alias ggproductions2010="cd ~/Development/ggproductions2010" | |
| # Sets ggproductions2010 as cd ~/Development/ggproductions2010/boxscoreandmore | |
| alias boxscoreandmore="cd ~/Development/ggproductions2010/boxscoreandmore" | |
| # Sets hiqlabs as cd ~/Development/hiqlabs | |
| alias hiqlabs="cd ~/Development/hiqlabs" | |
| # Sets keeper as cd ~/Development/hiqlabs/keeper | |
| alias keeper="cd ~/Development/hiqlabs/keeper" | |
| # Sets platform as cd ~/Development/hiqlabs/platform | |
| alias platform="cd ~/Development/hiqlabs/platform" | |
| # Todo | |
| # Opens the todo file | |
| alias todo="subl ~/Desktop/TODO.md" | |
| # Opens the hiqlabs todo file | |
| alias hiqtodo="subl ~/Development/hiqlabs/HIQTODO.md" | |
| # Test Sandbox aliases | |
| # Sets testjs as subl ~/Development/sandbox/test.js | |
| alias testjs="subl ~/Development/sandbox/test.js" | |
| # Sets testpy as subl ~/Development/sandbox/test.py | |
| alias testpy="subl ~/Development/sandbox/test.py" | |
| # Sets testgo as subl ~/Development/sandbox/test.go | |
| alias testgo="subl ~/Development/sandbox/test.go" | |
| # Sets testcpp as subl ~/Development/sandbox/test.cpp | |
| alias testcpp="subl ~/Development/sandbox/test.cpp" | |
| # Application aliases | |
| # Opens the current directory in Finder | |
| alias finderd="open -a Finder ./" | |
| # Opens the current directory in Sublime | |
| alias subld="subl ." | |
| # Tmux aliases | |
| # Starts a new session with the given name | |
| alias tmn="tmux new -s" | |
| # Attaches to the session with the given name | |
| alias tma="tmux attach -t" | |
| # Kills the session of the given name | |
| alias tmk="tmux kill-session -t" | |
| # Lists out all the sessions | |
| alias tmls="tmux ls" | |
| # Github aliases | |
| alias gb="git branch" | |
| alias gbd="git branch -D" | |
| alias gs="git status" | |
| alias ga="git add" | |
| alias gc="git commit" | |
| alias gcm="git commit -m" | |
| alias gca="git commit --amend" | |
| alias gl="git log" | |
| alias glo="git log --pretty=oneline" | |
| alias glg="git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short" | |
| alias gco="git checkout" | |
| alias gfo="git fetch origin" | |
| alias gm="git merge" | |
| alias gr="git remote -v" | |
| alias gra="git remote add" | |
| alias grr="git remote rm" | |
| alias gpushom="git push origin master" | |
| alias gpullom="git pull origin master" | |
| alias gpushum="git push upstream master" | |
| alias gpullum="git pull upstream master" | |
| alias gd="git diff" | |
| alias gpusho="git push origin" | |
| alias gcob="git checkout -b" | |
| alias gcp="git cherry-pick" | |
| # Docker aliases | |
| alias dk="docker" | |
| # Run an image | |
| alias dkr="docker run" | |
| # Show all images on this machine | |
| alias dki="docker images" | |
| # Show all running containers on this machine | |
| alias dkc="docker ps -a" | |
| # Removes an image | |
| alias dkir="docker rmi" | |
| # Removes a container | |
| alias dkcr="docker rm" | |
| # Clears out all current containers | |
| alias dkcc="docker stop $(docker ps -a -q) && docker rm -v $(docker ps -a -q)" | |
| # Docker Compose aliases | |
| # alias dkc="docker-compose" | |
| # Starts up Docker Compose | |
| alias dkcup="docker-compose up" | |
| # Restarts up Docker Compose | |
| alias dkcr="docker-compose restart" | |
| # Shuts down Docker Compose | |
| alias dkcd="docker-compose down" | |
| # Rancher aliases | |
| alias rdev="rancher --env=1a48" | |
| alias rstaging="rancher --env=1a50" | |
| alias rprod="rancher --env=1a49" | |
| # List all of the running containers in the current Rancher environment | |
| alias rc="rancher ps -c" | |
| # List all of the environments | |
| alias renv="rancher env" | |
| # Helper functions | |
| # Shows git branch in prompt | |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
| } | |
| export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " | |
| # Combines mkdir and cd into one command | |
| mkcd() { | |
| mkdir "$1" | |
| cd "$1" | |
| } | |
| # Extract most of known 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 | |
| } | |
| # Opens the github page for the current git repository in | |
| gh() { | |
| giturl=$(git config --get remote.origin.url) | |
| if [ "$giturl" == "" ] | |
| then | |
| echo "Not a git repository or no remote.origin.url set" | |
| exit 1; | |
| fi | |
| giturl=${giturl/git\@github\.com\:/https://github.com/} | |
| giturl=${giturl/\.git/\/tree/} | |
| branch="$(git symbolic-ref HEAD 2>/dev/null)" || | |
| branch="(unnamed branch)" # detached HEAD | |
| branch=${branch##refs/heads/} | |
| giturl=$giturl$branch | |
| open $giturl | |
| } | |
| # Makes a Google search on Chrome | |
| google() { | |
| if [ $# -eq 0 ] | |
| then | |
| open /Applications/Google\ Chrome.app/ "http://www.google.com"; | |
| else | |
| open /Applications/Google\ Chrome.app/ "http://www.google.com/search?q= $1"; | |
| fi | |
| } | |
| # Makes a Quora search on Chrome | |
| quora() { | |
| if [ $# -eq 0 ] | |
| then | |
| open /Applications/Google\ Chrome.app/ "https://www.quora.com"; | |
| else | |
| open /Applications/Google\ Chrome.app/ "https://www.quora.com/search?q= $1"; | |
| fi | |
| } | |
| # Makes a Wikipedia search on Chrome | |
| wikipedia() { | |
| if [ $# -eq 0 ] | |
| then | |
| open /Applications/Google\ Chrome.app/ "http://en.wikipedia.org"; | |
| else | |
| open /Applications/Google\ Chrome.app/ "http://en.wikipedia.org/wiki/Special:Search?search= $1"; | |
| fi | |
| } | |
| # killport will tell you the name of the killed process, or it will let you know if it couldn't find any process with that port open | |
| # https://gist.github.com/noahlt/1306985 | |
| function killport { | |
| if [ $1 == '-h' ] || [ -z $1 ]; then | |
| echo '`killport <PORT>` finds the process listening to the specified port and kills it.' | |
| else | |
| process_line=`sudo lsof -i :$1 | tail -1` | |
| if [ "$process_line" == "" ]; then | |
| echo "no processes listening on $1" | |
| else | |
| process_name=`echo "$process_line" | awk '{print $1}'` | |
| echo "killing $process_name" | |
| sudo kill `echo "$process_line" | awk '{print $2}'` | |
| fi | |
| fi | |
| } | |
| # Setting PATH for Python 3.4 | |
| # The orginal version is saved in .bash_profile.pysave | |
| PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}" | |
| export PATH | |
| # Setting PATH for Python 3.4 | |
| # The orginal version is saved in .bash_profile.pysave | |
| PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}" | |
| export NVM_DIR="/Users/derrickchie/.nvm" | |
| [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
| # for mysql command line | |
| export PATH=$PATH:/usr/local/mysql/bin | |
| export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi' | |
| colorized_grep() { | |
| grep --color -E $@ | |
| } | |
| alias grep=colorized_grep | |
| # Calls .bashrc everytime you login to your machine from a console | |
| # http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html | |
| if [ -f ~/.bashrc ]; then | |
| source ~/.bashrc | |
| fi | |
| # If you need help deciding between .bash_profile, .profile, and .bashrc | |
| # http://superuser.com/questions/789448/choosing-between-bashrc-profile-bash-profile-etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment