Wednesday, April 6, 2011

Fixing my Bash Prompt on OSX

I have been having a problem with the bash prompt. When I use the up and down arrows to scroll throw the history buffer, the output of the previous commands would get garbled and not line up. After messing around for 20 minutes I found a solution.

My old prompt:

PS1='\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[0;31m\]$(parse_git_branch_and_add_brackets)\[\033[00m\]\$ '


My new prompt:

PS1='\[\e[01;32m\]\u@\h:\[\e[01;34m\]\w\[\e[0;31m\]$(parse_git_branch_and_add_brackets)\[\e[0m\]$ '


Something about changing the \033 to \e works. Why? I don't know, if you do please comment.

Monday, March 7, 2011

BASH Prompt in OSX with git branch

I found others doing the same.

Here is the content of my ~/.profile.


function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}

PS1="\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[0;31m\]\$(parse_git_branch_and_add_brackets)\[\033[00m\]\\$ "

Saturday, February 19, 2011

Quickly rename files to lower case

Here is a simple bash oneliner to rename all folders/files in a directory to lower case

for old in * ; do new=`echo $old | tr "[[:upper:]]" "[[:lower:]"`; mv $old $new;  done;

Monday, February 14, 2011

Getting PHP's pcntl working on Snow Lepard

(make sure you've installed Apple's developer tools)


1. Check your version you have installed and download the PHP source code.

$ php -v
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

$ curl -O http://us.php.net/distributions/php-5.3.3.tar.gz


2. unpack, phpize, configure, make, make install

$ tar -xzvf php-5.3.3.tar.gz
$ cd php-5.3.3/ext/pcntl/
$ phpize
$ ./configure
$ make
$ sudo make install


3. Add "extension=pcntl.so" to your /etc/php.ini

4. Confirm

$ php -i | grep pcntl
pcntl
pcntl support => enabled


Done

Friday, December 31, 2010

New Year's Resolutions: New Passwords for 2011

I'll admit it. I've been bad. I'm a password reuse addict. I just love the way the muscle memory makes it so easy to type. And yes, I have a couple variations on the theme, but I've known for a long time that I would have to get clean. The recent gawker compromise has given me the push I need.

A couple of years ago I've started using LastPass. LastPass offers many nifty security features, but I use it b/c I move between computers, and it fills my forms in for me. (lazy.) Well no more! Time to leverage LastPass to it's potential.

Tonight I'm going clean. No more password reuse for 2011.

Thursday, November 15, 2007

Windows Re-install

Whenever I have a fresh install of XP (twice this week) I have a set of software I need to install.

Sunday, October 14, 2007

WOL

http://ubuntuforums.org/showthread.php?t=234588