Skip to content

Instantly share code, notes, and snippets.

View afeijo's full-sized avatar
🏠
Working from home

Alessandro Feijó afeijo

🏠
Working from home
View GitHub Profile
# Shortcut usage:
# curl -L http://bit.ly/feijo_tweaks | sh
echo Bash Aliases
wget https://gist.githubusercontent.com/afeijo/0c8c16c1726a27d4d1f4476c1f7cf53d/raw/118a33d210ec5d1d1ee1edad49679a83154e8343/.bash_aliases
echo ps1 colors
wget https://gist.github.com/afeijo/8601619/raw/a13d121b0abe2e4d0603612b744238c77b7d59ad/.ps1_color
curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > ~/.bash_git
alias ..='cd ..'
alias ...='..;..'
alias ....='...;..'
alias .....='...;...'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias df='df -h'
alias du='du -h'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
# this works for debian, ubuntu and similar
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
@afeijo
afeijo / new drupal project
Created September 20, 2017 01:07
Create a new Drupal project
if [[ $# -eq 0 ]] ; then
echo 'you forgot the new site name'
exit 0
fi
echo 'Creating site $1'
time drush dl --destination=/www --drupal-project-rename=$1
cd $1
mysql -e 'create database $1'
time drush si --account-name=admin --account-pass=102030 [email protected] --site-name="$1" --db-url=mysqli://root:1234@localhost/$1 -y
@afeijo
afeijo / .ps1_color
Last active August 14, 2020 01:22
My colored linux prompt
# download me or copy & paste into your root folder, name it .ps1_color
# add the line below into your ~/.profile or ~/.bashrc
# source ~/.ps1_color
# ANSI color codes
RS="\[\033[0m\]" # reset
HC="\[\033[0;1m\]" # hicolor
UL="\[\033[4m\]" # underline
INV="\[\033[7m\]" # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
@afeijo
afeijo / .vimrc
Last active February 9, 2018 12:25
My VIM configuration
set expandtab
set tabstop=2
set shiftwidth=2
set autoindent
set smartindent
if has("autocmd")
" Drupal *.module and *.install files.
augroup module
autocmd BufRead,BufNewFile *.module set filetype=php
@afeijo
afeijo / new_module.sh
Last active December 21, 2015 04:58
Bash script to create the skeleton files for a new Drupal 7 module
#!/bin/bash
# usage: download the script, place it in the modules folder, and execute with your new module name as the parameter.
# bash new_module.sh CustomModule
mkdir $1
cd $1
## .info file
echo "name = $1" > $1.info
@afeijo
afeijo / sites.sh
Created June 27, 2012 13:20
Backup all sites files
#!/bin/bash
# crontab example:
# 2 */12 * * * /bin/sh /home/user/scripts/sites.sh
# Local directory for dump files
LOCALDIR=$HOME/backups/sites
#
#####################################
### Edit Below If Necessary #########
#####################################
@afeijo
afeijo / mysql.sh
Created June 27, 2012 13:17
Mysql automated backup
#!/bin/bash
##########################################################################
#
# mysql_backups.sh: A shell script to back up all MySQL databases in
# one shot, nightly, and keep a rolling 3 weeks of
# backups hot, online in the backup archive.
#
# Written by David A. Desrosiers
# Contact [email protected]
# Last updated Jun 27 2012 by Alessandro Feijó @afeijo
@afeijo
afeijo / .screenrc
Created June 16, 2012 02:39
My .screenrc and .bashrc files
startup_message off
vbell off
autodetach on
#escape /
defscrollback 5000
#caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= %c"
hardstatus alwayslastline
hardstatus string '%{= kG}%{C}Screen: %{c}%{= kG}[%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{C} %d-%m %{W}%c %{g}]'