.bashrc
Here's a list of useful .bashrc rules:
Set date in history:
export HISTTIMEFORMAT="%Y-%m-%d %T "
Disable annoying error sounds:
bind 'set bell-style none'
Reload the .bashrc file:
source ~/.bashrc
Check PHP syntax recursively:
function phplr()
{
if [ -z $1 ]; then
echo -e "\e[93mPlease set path to check.";
else
if [[ -d $1 ]]; then
result=`find "$1" -iname "*.php" -exec php -l {} \; | grep -i "Errors.parsing"`
if [ -z "$result" ]; then
echo -e "\e[32mSyntax is OK";
else
echo -e "\e[31m$result";
fi
#find "$1" -iname "*.php" -exec php -l {} \; | grep -i "Errors.parsing"
else
echo -e "\e[93mThe path is not a directory.";
fi
fi
}
Show the current git branch in the terminal
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h \[\e[32m\]\w \[\e[93m\]\$(parse_git_branch)\[\e[00m\]$ "
Run CakePHP command:
cmd() {
cd /your/path && docker-compose exec web bin/cake $(sed "s/Command//g" <<< $1) ${@:2}
}
"${@:3:4}" will get you up to four arguments starting at "$3"