Chris Tankersley

· PHP Jack of All Trades ·

I spend a lot of the day in nano. It's a quick and easy way to edit text from the command line in Linux, and my editor of choice. I've started programming in Python and use nano when I need to do a quick edit. To help me find what I needed, I enabled syntax highlighting.

NOTE: The following instructions set up the nano settings for your user. If you want to change the settings for everyone, you will need to edit /etc/nanorc instead of ~/.nanorc

If you have nano already installed, the first thing you need to do is find the default nanorc file. In Ubuntu, I found this in /etc/nanorc (this is a global default file for all users). To find yours, search for 'nanorc' or 'nanorc.sample.gz'. Copy or exact the file into your home directory and name it '.nanorc'.

  • Copy to your home directory: cp /etc/nanorc ~/.nanorc

  • Extract sample to home directory: zcat /usr/doc/nano-x.x.x/nanorc.sample.gz >~/.nanorc

Open up the file in nano. By default all of the options are commented out. Go through the file and uncomment what settings you want to turn on. Since Python is whitespace-dependant I also enabled auto-indentation.

The file should be fairly well commented. Search for Python or what ever language you want to enable syntax highlighting for and uncomment it. Some installations will have the full code that you need to uncomment or just a link to the file that contains the actual highlighting rules.

Once you are finished uncommenting what you need, save and exit the file. Test it by opening an appropriate file and everything should be color-coded!

Posted on 2007-07-01

Comments


Ubuntu has released the newest alpha version of Gutsy Gibbon. Gibbon will have Compiz Fusion (the newest release since Compiz and Beryl merged) enable by default, along with all of the enhancements of Feisty Fawn.

More information here: http://www.ubuntu.com/testing/tribe2

Posted on 2007-06-29

Comments


One of the best things about *nix-based systems is the rich command line interface that they all have. No matter what shell you actually use, the entire operating system is at your fingertips with a terminal. The only downside is that multiple windows must be open to do multiple things, right? Not with screen, a basic window manager for terminals. Open multiple sessions and even split-screen to make your life easier. Find out how after the jump.

Screen is easily installed from any package management system. Assuming it isn't installed by default, screen should be in the repository for whatever package management system your OS uses (apt, pkg_add, yum, etc). Once installed, a world of possibilities is open to you.

Starting 'screen'

You can invoke screen from the command line by typing just 'screen' and hitting enter. With this basic command, a new virtual terminal is created inside the terminal that you were just in. This terminal acts just like any other command line in your OS. Still not exciting? Try this:

Start a ping command with 'ping localhost' and let it run. After a few seconds, hit 'CTRL+a then d'. This will drop you back to your original terminal. But what happened to your ping command? It is actually still running in the background. Unlike a regular terminal, screen will continue to run in the background even after you have detached from it (assuming you don't exit fully out). You can rejoin your ping session by invoking screen like this:

screen -d -r

You can see that your ping command is still running! You can now end the ping and fully exit the screen program by typing 'exit'.

Window Management

screen handles more than just one virutal terminal at a time. You can think of each instance of screen as a separate window, and you can have multiple windows open at once. Once you areinside of screen, you can create new windows by typing 'CTRL+a c'. This makes you a new terminal screen and takes you immediately to it. You can cycle through your windows by going to the next window with 'CTRL+a n' or back to the previous window with 'CTRL+a p'

Split Screen

screen also has the functionality of splitting your terminal screen in two. Trying to run a program but want to watch a log file at the same time? Edit and run the program in the top region and watch the log file in the lower. To go split screen, type 'CTRL+a S'. You can move between the screens with 'CTRL+a TAB'. Remember that splitting a screen doesn't automatically create a new window to work in, so after you move into the lower region, create a new screen with 'CTRL+a c'.

Other Common Commands

Here are some other commands that you will find useful while using screen. All of the following commands are preceded by CTRL+a:

Create a new Window:

c

List all Windows:

"

Move to Next Window:

n

Move to Previous Window:

p

Remove current Region:

x

Scroll Mode:

[

Split Display:

S

Switch to Other Region:

TAB

Posted on 2007-06-19

Comments