Skip to content

Instantly share code, notes, and snippets.

@williankeller
Last active October 26, 2015 13:26
Show Gist options
  • Select an option

  • Save williankeller/3fbdd88e101ecc7743d6 to your computer and use it in GitHub Desktop.

Select an option

Save williankeller/3fbdd88e101ecc7743d6 to your computer and use it in GitHub Desktop.
# Use to open context 'subl ~/.bashrc'
MYSQL_USER="root"
MYSQL_PASS="admin"
# Restart Apache.
fapache_restart() {
sudo service apache2 restart
}
# MySQL login.
fmysql_login() {
mysql -u $MYSQL_USER -p$MYSQL_PASS
}
#Configure local database after restoring with stage/prod one
fdatabase_configure() {
drush vset file_temporary_path /tmp
drush vset autologout_enforce_admin 0
drush vset autologout_timeout 10000
drush vset autologout_padding 10000
drush vset page_cache_maximum_age "0"
drush vset cache_lifetime "0"
drush vset cache 0
drush vset block_cache 0
drush vset page_compression 0
drush vset preprocess_css 0
drush vset preprocess_js 0
drush cc all
}
#SOLR re-index
fsolr_reindex(){
drush solr-delete-index
drush solr-mark-all
drush solr-index
drush cron && drush cc all
}
#Open Apache2 generic.conf to edit vhosts
fvhost_config(){
sudo vim /etc/apache2/sites-available/generic.conf
}
#Update theme - npm, bundle and grunt
ftheme_updater(){
sudo npm update
bundle update
grunt -v --force
}
# Open chrome
open_chrome_only() {
google-chrome
}
# Open chrome
open_chrome_private() {
google-chrome -incognito
}
# Open netbeans
beans() {
~/netbeans-8.0.2/bin/netbeans
}
# Custom prompt to open google URL
google_url() {
query=""
for q in $@
do
query="${query}${q}+"
done
google-chrome --args "http://www.google.com/search?q=${query}"
}
# Custom prompt to open any URL
chrome_open() {
query=""
for q in $@
do
query="${query}${q}"
done
google-chrome --args "${query}"
}
# Alias
alias tu=ftheme_updater
alias vc=fvhost_config
alias ra=fapache_restart
alias ml=fmysql_login
alias rd=fdatabase_configure
alias sr=fsolr_reindex
alias chrome=open_chrome_only
alias chromef=google_url
alias chromep=open_chrome_private
alias chromeo=chrome_find
# Custom prompt with current git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
PS1="\n$GREEN\u@\h$NO_COLOR:\w\n$YELLOW\$(parse_git_branch)$NO_COLOR\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment