Last active
February 4, 2016 15:34
-
-
Save nkbt/71632c927684602f6911 to your computer and use it in GitHub Desktop.
.bashrc with git helpers and deployment
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
# .bashrc | |
PS1="\[\033[1;30m\][\[\033[1;34m\]\u\[\033[1;30m\]@\[\033[0;35m\]\h\[\033[1;30m\]] \[\033[0;37m\]\W \[\033[1;30m\]\$\[\033[0m\] " | |
export PATH=~/npm/bin:$PATH | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
EDITOR=nano | |
LANG=en_US.UTF-8 | |
# User specific aliases and functions | |
alias ls='ls -hA --color' | |
alias ll="ls -lv --group-directories-first" | |
alias fl="forever list" | |
alias fr="forever restart" | |
alias gitlog1="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" | |
alias gitlog2="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all" | |
alias gitlog=gitlog1 | |
alias gitsw="git checkout" | |
alias gitbr="git branch" | |
alias gitpl="git pull --prune" | |
alias gitmr="git merge" | |
alias bashrc="source ~/.bashrc" | |
function foreverStart { | |
app=$1 | |
env=$2 | |
mkdir -p /log/$app.$env | |
NODE_ENV=$env forever start --sourceDir /web/apps/$app.$env --pidFile /web/apps/$app.$env/forever.pid -a -l /log/$app.$env/forever-node.log -e /log/$app.$env/forever-error.log -o /log/$app.$env/forever-out.log app.js | |
} | |
function foreverRestart { | |
app=$1 | |
env=$2 | |
forever restart $(forever list | grep `cat /web/apps/$app.$env/forever.pid` | grep --perl-regexp --regexp=\\[\\d+\\] --only-matching | tr -d '[]') | |
} | |
function releaseGetVersion { | |
app=$1 | |
env=$2 | |
DIRECTORY=/web/apps/$app.$env | |
if [ -d "$DIRECTORY" ]; then | |
cd /web/apps/$app.$env && git describe --abbrev=0 --tags | |
else | |
echo "" | |
fi | |
} | |
function release { | |
env=$1 | |
app=$2 | |
tag=$3 | |
# "install", "update", or nothing | |
mode=$4 | |
cd /web/apps/$app.$env | |
git fetch origin; | |
git checkout $tag | |
git pull | |
if [[ $mode == i* ]]; then | |
npm install | |
bower install | |
fi | |
if [[ $mode == u* ]]; then | |
npm update | |
bower update | |
fi | |
grunt | |
foreverRestart $app $env | |
} | |
function releaseDev { | |
release dev $@ | |
} | |
function releaseLive { | |
release live $@ | |
} | |
# GIT bash prompt | |
GIT_PROMPT_ONLY_IN_REPO=1 | |
source ~/.bash-git-prompt/gitprompt.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment