Aliases

Git branch info in command line

First Install:

https://git-scm.com/downloads


Next, move your current aliases and so forth to new file called e.g. .profile.

Go to .bash_profile and add following lines:

source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
source ~/.profile

In .profile add:

PS1='\[\e[0;36m\]\u\[\e[m\] \[\e[0;34m\]\w\[\e[m\] \[\e[0;32m\]$(__git_ps1 "(%s)")\[\e[m\] $ '

Change directory to qcadoo and You should see:

user ~/qcadoo-src/qcadoo (master) $

Useful aliases

Working with repository

qcadoosrc=~/qcadoo-src

alias qcadoospc='cd ${qcadoosrc}/qcadoo-super-pom-closed/'
alias qcadoospo='cd ${qcadoosrc}/qcadoo-super-pom-open/'
alias qcadoomp='cd ${qcadoosrc}/qcadoo-maven-plugin/'
alias qcadoo='cd ${qcadoosrc}/qcadoo/'

alias mes='cd ${qcadoosrc}/mes/'
alias mesa='cd ${qcadoosrc}/mes/mes-application/'
alias mesp='cd ${qcadoosrc}/mes/mes-plugins/'
alias mesc='cd ${qcadoosrc}/mes-commercial/'

alias schema='cd ${qcadoosrc}/mes/mes-application/src/main/resources/schema'

alias demo='cd ${qcadoosrc}/demo-database/'

Working with git

alias status='git status'
alias pull='git pull'
alias push='git push'
alias commit='git commit'
alias branch='git branch'
alias checkout='git checkout'
alias merge='git merge --no-ff'
alias last='git last'
alias log='git log --pretty=format:"%h - %C(cyan)%an%C(reset) %C(blue)(%ar)%C(reset) %s %C(bold green)%d%C(reset)"'

Pretty console

git config --global color.ui true

Working with tomcat

Tomcat directory

tomcatsrc=mes/mes-application/target/tomcat-archiver/mes-application

alias mest='cd ${qcadoosrc}/${tomcatsrc}/'
alias mesl='cd ${qcadoosrc}/${tomcatsrc}/webapps/ROOT/WEB-INF/lib/'

Tomcat running

alias chmodx='chmod +x ${qcadoosrc}/${tomcatsrc}/bin/*.sh'

alias tomcat_start='${qcadoosrc}/${tomcatsrc}/bin/startup.sh'
alias tomcat_stop='${qcadoosrc}/${tomcatsrc}/bin/shutdown.sh'
alias tomcat_debug='${qcadoosrc}/${tomcatsrc}/bin/catalina.sh jpda start'

alias tomcat_less='while [ ! -f ${qcadoosrc}/${tomcatsrc}/logs/root.log ]; do echo -n; done && less ${qcadoosrc}/${tomcatsrc}/logs/root.log'

alias rm_pid='rm ${qcadoosrc}/${tomcatsrc}/catalina.pid'

Coping lib from target to tomcat directory

alias cp_tomcat='cp target/*.jar ${qcadoosrc}/${tomcatsrc}/webapps/ROOT/WEB-INF/lib/'

Changing database properties

dbproperties=${qcadoosrc}/${tomcatsrc}/qcadoo/db.properties

function db_replace() { sed -i "" "s/\(dbJdbcUrl=jdbc:postgresql:\)\([a-z0-9_]*\)/\1$1/g" $dbproperties; }; 
function hbm_replace() { sed -i "" "s/\(hibernateHbm2ddlAuto=\)\([a-z0-9_]*\)/\1$1/g" $dbproperties; }

alias db_replace='db_replace'
alias hbm_replace='hbm_replace'

alias db_show='cat $dbproperties'

Usage:

db_replace mes_test
hbm_replace validate

Working with postgres

function create_db() { createdb $1 -U postgres; };
function drop_db() { dropdb $1 -U postgres; };
function open_db() { psql -U postgres $@;};
function dump_db() { pg_dump -U postgres $1 -O > $1$2.sql; };
function update_db() {
	MES_VERSION=`ls -1 ${qcadoosrc}/mes-commercial/sql/ | sort -gr | head -1`
	SCHEMA_VERSION=`ls -1 ${qcadoosrc}/mes-commercial/sql/$MES_VERSION/ | sort -gr | head -1`

    psql -U postgres $1 -f ${qcadoosrc}/mes-commercial/sql/$MES_VERSION/$SCHEMA_VERSION/bulk$SCHEMA_VERSION.sql
}

alias create_db='create_db'
alias drop_db='drop_db'
alias open_db='open_db'
alias dump_db='dump_db'
alias update_db='update_db'

alias show_db='psql -U postgres -l'

Usage:

create_db mes_test
drop_db mes_test
open_db mes_test
dump_db mes_test