Skip to content

Instantly share code, notes, and snippets.

@7ochem
7ochem / .bash_aliases
Last active March 13, 2016 20:28
Useful git and Magento bash aliases
alias gitstashpullrebasepop="HAS_STASH=\$(git stash) && git pull --rebase; RETVAL=\$?; test \$RETVAL -eq 0 -a \"\$HAS_STASH\" != \"No local changes to save\" && git stash pop; test \$RETVAL -ne 0 -a \"\$HAS_STASH\" != \"No local changes to save\" && echo 'Stashed changes:' && git stash list"
alias cc='test -d htdocs && HTDOCS="htdocs/" || HTDOCS="";rm -vrf "$HTDOCS"{var/{cache,full_page_cache}/*,media/{js,css}/*.{js,css}}|sed "s/mage--[0-9a-f]/mage--?/;s/mage---[A-Za-z0-9_-]\+/mage---*/"|sort -r|uniq -c'
alias cc+='test -d htdocs && HTDOCS="htdocs/" || HTDOCS="";test -d /tmp/magento && TMP_MAGENTO="/tmp/magento" || TMP_MAGENTO="";rm -vrf "$HTDOCS"{var/{cache,full_page_cache,session,report}/*,media/{{js,css}/*.{js,css},catalog/product/cache/*}} "$TMP_MAGENTO"|sed "s/mage--[0-9a-f]/mage--?/;s/mage---[A-Za-z0-9_-]\+/mage---*/;s/sess_[0-9a-z]\+/sess_*/;s/report\/[0-9]\+/report\/*/;s/media\/\(css\|js\)\/.\+/media\/\1\/*/;s/\(catalog\/product\/cache\/\).*/\1*/"|sort -r|uniq -c'
(MySQLDUMP_DATABASE=$(sed -n "s/^.*'db_name' => '\(.*\)'.*/\1/p" config.php | head -n1) \
&& MySQLDUMP_IGNORE_TABLES=$( \
mysql -h$(sed -n "s/^.*'db_host_name' => '\(.*\)'.*/\1/p" config.php | head -n1) \
-u$(sed -n "s/^.*'db_user_name' => '\(.*\)'.*/\1/p" config.php | head -n1) \
-p$(sed -n "s/^.*'db_password' => '\(.*\)'.*/\1/p" config.php | head -n1) \
$MySQLDUMP_DATABASE \
-e "SHOW TABLES LIKE '%_audit';" \
| tail -n+2 \
) && \
mysqldump -h$(sed -n "s/^.*'db_host_name' => '\(.*\)'.*/\1/p" config.php | head -n1) \
RESET_SALES_SQL_FILE=reset_sales_tables_$(date +%s).sql && \
(
mysqldump --add-drop-table --no-data -K -uroot -p***** DBNAME \
`echo $(mysql -uroot -p***** DBNAME -e "SHOW TABLES LIKE 'sales_flat%';" | tail -n+2)` \
`echo $(mysql -uroot -p***** DBNAME -e "SHOW TABLES LIKE 'sales%aggregated%';" | tail -n+2)` \
| sed 's/ AUTO_INCREMENT=[0-9]*\b//' && \
echo "UPDATE \`eav_entity_store\` SET \`increment_last_id\` = '100000000'" \
"WHERE \`entity_type_id\` IN(SELECT \`entity_type_id\` FROM \`eav_entity_type\` WHERE \`entity_model\` LIKE 'sales/%');"
) > $RESET_SALES_SQL_FILE && \
mysql -uroot -p***** DBNAME < $RESET_SALES_SQL_FILE && \
@7ochem
7ochem / vendor_repo_status.sh
Created February 13, 2015 13:50
Quickly check status of all your vendor repositories (for changes)
#!/bin/bash
find vendor/ -type d -name ".git"|sed 's/\/\.git$//'|xargs -I % sh -c 'echo "-> %";cd %; git status -su;'