Thursday, June 26, 2014

I hate VIM

Vim to me will always mean the household cleaner: but in the geek world of sysadmin... well, I'm sure it makes beginners scream too.

Like everything there are a few basics that never seem intuitive, so always have to root them out. So here's the most basic commands for server admin heaven:

i insert mode
ESC back to command mode
:q Exit
:w Write
:qa! Quit and abandon changes


h moves the cursor one character to the left.
j moves the cursor down one line.
k moves the cursor up one line.
l moves the cursor one character to the right.
0 moves the cursor to the beginning of the line.
$ moves the cursor to the end of the line.
w move forward one word.
b move backward one word.
G move to the end of the file.
gg move to the beginning of the file.
`. move to the last edit.


d starts the delete operation.
dw will delete a word.
d0 will delete to the beginning of a line.
d$ will delete to the end of a line.
dgg will delete to the beginning of the file.
dG will delete to the end of the file.
u will undo the last operation.
Ctrl-r will redo the last undo.

Wednesday, October 02, 2013

OSX Terminal - Colours for Directory Listing

If you're used to seeing a multi-coloured display when looking at directory contents: on most *nix systems, these listings have a colour code for directories, system files etc. In Mac's OSX Terminal, it's all just plain text.

One solution is use another shell app (I frequently use the one built into Pathfinder).

However, you can also turn the colour on for Terminal by editing the ~/.bash_profile file and adding the following lines:

# Add colours to Terminal 
export CLICOLOR=1 
export LSCOLORS=GxFxCxDxBxegedabagaced

Restart Terminal.

You're welcome

Tuesday, August 28, 2012

PHP Settings for Drush in OSX

Drush has been testing me...

Faced with the Fatal error: Allowed memory size of millions of bytes exhausted (tried to allocate a couple of bytes) message on practically every conceivable Drush operation, thought it was time to invest in my dev environment to sort my Mac out...

Turns out that the php.ini file used by your local web server is different to the one Drush uses on the command line. My local development server usually runs with memory_limit=512M (although hosted sites usually run with 256M or less).

To find out which version of PHP Drush uses, drush status may help. However, which php may give you the best answer: if it's /usr/bin/php and your Drush status PHP Configuration is blank, chances are PHP is running with a miniscule amount of memory resource for CLI-issued commands. In which case you need a new php.ini file in your /etc folder to give Drush more beef. There are already default ones in this folder, so just copy one of these and edit.

cd /etc 
sudo cp php.ini.default php.ini 
sudo chmod 666 php.ini 

Then edit your new php.ini file and set memory_limit=512M in the php.ini file.

If you need more help on understanding what php.ini is all about, there's a useful article at http://drupal.org/node/207036 and explains the various tweaks to help Drupal and Drush work well. Please note, not all hosting providers will allow you to adjust php.ini, especially the cheaper, shared hosting accounts.