12
Feb
2012

Code Highlighting in Terminal Mac

Ever wanted to highlight your code in mac’s terminal?  I recently set mine up to do just that and it makes things much easier visually when you have to go update a file or when you need to write a full application.  To start off, in mac’s terminal there is no color coding for different files / folders.  If you want this, it is very easy to do.  What you need to do is open up terminal.  Once you have it open, verify you are in your home directory.  You should be there by default, but if you are not, make sure you are.  You will then need to create a .bash_profile file.

 

You can do this by simply typing

1
 touch .bash_profile

 

Once you have that, if you want simple folder coloring you can put these strings in.

1
2
3
4
5
export CLICOLOR=1

export LSCOLORS="gxfxcxdxbxegedabagacad"

export CLICOLOR=cons25

 

This doesn’t do anything for code coloring though, and that is more of the issue of this post.  Whenever I need to change a file quickly, it is much easier and faster to SFTP into the system and update the file rather than waiting on dreamweaver to open, connect, browse to the file and then edit it.  Based on the current nano editor installed on your mac, you will not have this functionality.  You will need to install XCode which has a C compiler in it to update nano.  I obtained my nano version from here  http://www.nano-editor.org/download.php .

 

From there, you will want to use terminal to navigate to your downloads folder or wherever you stored your file.  Once in the folder containing the tar file for the newest version of nano, issue this command.

1
tar -xvf nano*

 

That will extract nano into a folder and then, you will want to navigate inside that folder you just extracted.  Here is where xCode will be important.  Once you are in the folder, you will issue these two commands which will configure and install the newest version of nano.

1
2
./configure
sudo make && make install

 

To get all of this to work with your mac, you will need to navigate to your user’s home directory again.  You will need to edit your .bash_profile again.  The string you will need to add is

1
export PATH=/usr/local/bin:$PATH

 

To make sure your version of nano is now updated you can type this in terminal.  At the time of this tutorial, I am using 2.2.6.

1
nano -V

 

To get your code syntax highlighted and color coded, you will need to add this to your .nanorc file.  It is located at the user’s base home directory.  It will be a hidden file (much like your .bash_profile) file, and if you want to see it, simply type this in terminal.

 

1
ls -Fal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
## Nanorc files
include "/usr/local/share/nano/nanorc.nanorc"

## C/C++
include "/usr/local/share/nano/c.nanorc"

## Cascading Style Sheets
include "/usr/local/share/nano/css.nanorc"

## Debian files
include "/usr/local/share/nano/debian.nanorc"

## Gentoo files
include "/usr/local/share/nano/gentoo.nanorc"

## HTML
include "/usr/local/share/nano/html.nanorc"

## PHP
include "/usr/local/share/nano/php.nanorc"

## TCL
include "/usr/local/share/nano/tcl.nanorc"

## TeX
include "/usr/local/share/nano/tex.nanorc"

## Quoted emails (under e.g. mutt)
include "/usr/local/share/nano/mutt.nanorc"

## Patch files
include "/usr/local/share/nano/patch.nanorc"

## Manpages
include "/usr/local/share/nano/man.nanorc"

## Groff
include "/usr/local/share/nano/groff.nanorc"

## Perl
include "/usr/local/share/nano/perl.nanorc"

## Python
include "/usr/local/share/nano/python.nanorc"

## Ruby
include "/usr/local/share/nano/ruby.nanorc"

## Java
include "/usr/local/share/nano/java.nanorc"

## AWK
include "/usr/local/share/nano/awk.nanorc"

## Assembler
include "/usr/local/share/nano/asm.nanorc"

## Bourne shell scripts
include "/usr/local/share/nano/sh.nanorc"

## POV-Ray
include "/usr/local/share/nano/pov.nanorc"

## XML-type files
include "/usr/local/share/nano/xml.nanorc"

 

This file will include all of the paths for your color codes in nano.  I didn’t like the default colors that nano offered so here are a couple that I changed to make them a little easier for me.

 

PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Here is an example for PHP
##
syntax "php" "\.php[2345s~]?$"

## php markings
color brightred "(<\?(php)?|\?>)"

## functions
color white "\<[a-z_]*\("

## types
color green "\<(var|float|global|double|bool|char|int|enum|const)\>"

## structure
color brightyellow "\<(class|new|private|public|function|for|foreach|if|while|do|else|elseif|case|default|switch)\>"

## control flow
color magenta "\<(goto|continue|break|return)\>"

## strings
color magenta "<[^=       ]*>" ""(\.|[^"])*""

## comments
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
#color blue start="<" end=">"
#color red "&[^;[[:space:]]]*;"

## Trailing whitespace
##color ,green "[[:space:]]+$"

 

CSS

1
2
3
4
5
6
7
8
9
## Here is an example for css files.
##
syntax "css" "\.css$"
color brightred     "."
color magenta  start="\{" end="\}"
color brightgreen   start=":" end="([;^\{]|$)"
color brightblue    ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
color brightblue    start="\/\*" end="\\*/"
color green         ";|:|\{|\}"

 

 

If you like this, or have some better color codes, let me know! Also, if you have any problems, let me know and I will be more than willing to help you!

13
Nov
2011

North Monroe Baptist Church

I got a new client the other day!  I met with their media pastor and we discussed a few ideas and came up with a game plan.  They wanted to take their outdated site and use a manageable framework like wordpress.  That being said, I set up the framework, wordpress, and created a database and got the site going.  After a few hrs of set up and tweaking, they are almost ready to begin creating pages and publishing data!  It has been a real pleasure working with them and I hope to get more clients like them along the way.  I am including a rough design of what their site will look like.  I am sure there will be a few more tweaks to be made.  I will probably also be integrating their archived videos and streaming services in the coming future.  Check it out and let me know what you think!

06
Nov
2011

Interesting iPhone App (Field Agent)

I have been pretty busy lately and haven’t had time to update in a while.  I need to do it at least once a week and hopefully I will get better at it. Recently one of my friends, Cameron Brister, introduced me to an iPhone app called Field Agent.  The basic premise of the app is kind of like a secret shopper type system.  You go to a store and basically give reviews.  At this point I haven’t had to buy anything, but that might be incorporated.  The benefit behind the reviews is cash!  How sweet is this?!  At first I thought because we live in a rural area there wouldn’t be much traffic from the app in our area.  I have used it for two days and I have already completed 3 tasks.

The tasks are quite easy and if you are in the area of the job are decent pay.  One of the tasks required me to go into Walmart and take a picture of the men’s electric grooming section and answer 4 questions.  It took me about 5 minutes and I made $5.50 for the task.  It is pretty simple!  Over the last two days I have already profited $15.00 from this app for doing almost nothing.  I am definitely interested to see if this keeps up.  In other news I have a few more business ideas and clients coming my way!  Hopefully I will keep this up!

26
Jul
2011

It’s Been a While…

Well…It seems like it has been a while since I have updated.  It isn’t really because I have forgot about my blog, but more along the lines of I have been extremely busy.  The Sawyer Plastics project is coming along great and hopefully in the next few weeks I can write a blog saying I have successfully finished this project!  I have pretty much put my free time for the last 6-7 months on hold to develop this thing and I will be glad once I get it wrapped up.  I will be happy for two reasons.  The foremost is that this will be the first project of this scope my company NewRockIT has completed.  The second will be that it will free me up for some other development projects and business prospects I would like to look into.  My company has done several projects in the past, but nothing has compared to the scope of this one and it will be a great launch for both parties involved we feel.Once you start a project of this scope it seems like more freelance jobs come through!  My company is continuing to grow at a moderate speed and I hope it increases exponentially after the launch of this project.

In other news outside of Sawyer, I have had a few small freelance deals.  One of which is with Superlift Suspensions.  I am building a custom integration into their SAP System.   I am using jQuery and jQuery UI to develop a web app that will query the SAP database and create for them some printable information.  I am doing the server side scripting in ASP and SAP runs on a MSSQL Database.  It is almost wrapped up and I can’t wait for this one to go live either.  It has been a great project and I hope to do a lot more business w/those guys.

I also picked up a few new clients Woodlawn Baptist Church who I am doing site hosting for and Samurai One which we worked with SquarePlanIT to do a photo shoot and site redesign.

In other news, I might be purchasing a business car.  This is awesome in my opinion.  It will be the first large scale item I have purchased for the business.  I have a few ideas in mind but I would like to hear your input.  I want something unique that I could add some advertisements for my business too.  So, what do you think?

Hopefully as time goes by I will update more!

 

02
May
2011

Updated Quote/Order Management

We are still working on the quote system in the Sawyer project.  They have 5 addresses associated with a quote.  A bit to wrap one’s mind around.  Here is the current idea for the design.  What ya think?