Categories
OSX

Git Completion with Terminal/iTerm output theme

Install Git Completion:

Save the git-completion.bash file in your home directory:

Installation

Open your .bash_profile

nano ~/.bash_profile

Paste the following at the top of the file, make sure not to overwrite any other settings you may have put in the file.

###### GIT COMPLETION - START ######
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}

# Colour Variables
BLACK="\[\033[0;30m\]"
BLACKBOLD="\[\033[1;30m\]"
RED="\[\033[0;31m\]"
REDBOLD="\[\033[1;31m\]"
GREEN="\[\033[0;32m\]"
GREENBOLD="\[\033[1;32m\]"
YELLOW="\[\033[0;33m\]"
YELLOWBOLD="\[\033[1;33m\]"
BLUE="\[\033[0;34m\]"
BLUEBOLD="\[\033[1;34m\]"
PURPLE="\[\033[0;35m\]"
PURPLEBOLD="\[\033[1;35m\]"
CYAN="\[\033[0;36m\]"
CYANBOLD="\[\033[1;36m\]"
WHITE="\[\033[0;37m\]"
WHITEBOLD="\[\033[1;37m\]"
RESETCOLOR="\[\e[00m\]"
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)


# Define the terminal output string: username in path - branch
export PS1="${REDBOLD}\u ${RESETCOLOR}in ${CYANBOLD}\w ${GREEN}-\$(parse_git_branch)${RESETCOLOR} $ "


# Include the git completion file (must be saved in your home directory for this to work)
# Source: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
if [ -f ~/.git-completion.bash ]; then
 . ~/.git-completion.bash


 # Add git completion to aliases
 __git_complete gco _git_checkout
 __git_complete gb _git_branch
 __git_complete gc _git_commit
fi
###### GIT COMPLETION - END ######

Reload .bash_profile

source ~/.bash_profile
Categories
Web Development

Import large database files to MySQL using Terminal with MAMP

/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -proot DBNAME < /Users/robertannett/Downloads/DBFILENAME.sql

 

Categories
Web Development

List all ports in use

netstat -lp

List all services using a specific port

netstat -lp | grep 3306

 

Categories
OSX Web Development

Install ext-intl on Mac OSX using homebrew and XAMPP

This was a painful process for me, it took quite a while to figure out why such a simple implementation when using ubuntu, can be so much work in a Mac.

We can’t just install the extension with apt-get like ubuntu, and its not already waiting to be uncommented like in windows, we have to install the the shared object intl.so our selves.  and the easiest way of doing this is by using homebrew and pecl.

Step 1 – Install Homebrew

Homebrew Website: http://brew.sh

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2 – Install Install icu4c

ICU4C Website: http://site.icu-project.org

brew install icu4c

Step 3 – Install Autoconf

More about Autoconf: http://brewformulas.org/Autoconf

brew install autoconf

Step 4 – Install Intl via PECL

PECL Website: https://pecl.php.net

sudo pecl update-channels
sudo pecl install intl

Step 5 – Enable intl.so in php.ini

Go to your php.ini file and at the end, add the following line:

extension=intl.so

This will enable the extension that we have just installed.

Step 6 – Restart your server

Use XAMPP to restart your server, this will reload the php.ini file with the new configuration.

Step 7 – Check it worked!

You can check if Intl was installed successfully by using the following command to list the loaded php modules.  If ‘intl‘ it is listed then it has been successfully loaded.

php -m

I am running php via Terminal and it didn’t work?

One common problem is that terminal is using the the wrong version of php, sometimes a system default is loaded rather than the php version you are using in XAMPP.  First lets check what version we are using:

which php

If you are using XAMPP correctly it should return:

  • /Applications/XAMPP/xamppfiles/bin/php 

If not and it loads from:

  • /usr/bin/php

Then we can temporarily change the path of the default php version to the XAMPP version by running the following in terminal:

PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"

Now if you run “which php” in terminal again you should get the correct path.

 

 

Categories
Ubuntu

Clone Entire Website with WGET in Terminal

Option 1:

wget --recursive --no-clobber --page-requisites --html-extension --convert-links --domains www.yourdomain.com www.yourdomain.com

Option 2:

wget -r --convert-links --html-extension --no-parent www.yourdomain.com