How to fix ESC[ in your terminal

Posted June 13, 2011 under General, Hacking, Ubuntu

I don’t know exactly what happened the other day, but I ran a git diff and instead of the usual red and green colors, everything was some form of ESC[32m ESC[1m ESC[m and so on in order to tell the terminal to switch colors.

ESC[1mindex 6008531..985ce31 100755ESC[m
ESC[1m--- a/bin/build-site.pyESC[m
ESC[1m+++ b/bin/build-site.pyESC[m
ESC[36m@@ -1,5 +1,9 @@ESC[m
 #!/usr/bin/env pythonESC[m
 ESC[m
ESC[32m+ESC[m
ESC[32m+ESC[m
ESC[32m+ESC[m
ESC[32m+ESC[m
 import getoptESC[m
 import gitESC[m
 import osESC[m

Okay this is just great. No idea what is going on, and I can’t possibly continue coding like this. After a bit of googling, there wasn’t much on the situation.

It turns out that the less command got misconfigured. I was working on Ubuntu and found the culprit to be the $LESS environment variable misconfigured.

$ echo $LESS
-eiMX
$ export LESS="-eirMX"

These two commands in terminal will print out the $LESS environment variable and then set it. The “r” option is what is crucial here. It’s what enables coloring in less output. Another environment variable you may look at is $PAGER.

Take a look here for a really good description of the problem: http://www.xcombinator.com/2008/07/23/mac-os-x-color-showing-escwhatever-for-git-diff-colors-and-more/


Upgrading to Dropbox 1.0 on Ubuntu

Posted December 21, 2010 under General, Ubuntu

Dropbox has to be one of my favorite services. I honestly don’t know what I would do without it.

Recently Dropbox moved up to version 1.0. Awesome! Right? Well, how do you upgrade to it in Ubuntu? The nautlius-dropbox package you installed didn’t receive an upgrade because no Dropbox repository was added to your sources. So what do we do?

Simple. Just stop Dropbox and remove the daemon.

Dropbox
Step 1) Close Dropbox
Step 2) Open up Terminal
Step 3) rm -rf ~/.dropbox-dist
Step 4) Start Dropbox again from Applications->Internet->Dropbox

Let Dropbox install the proprietary daemon again, and once it’s done, you’ll be happy to see that Dropbox 1.0 is installed and running. Complete with Selective Sync! :D


Asus 3070 Wireless USB and Ubuntu

Posted November 19, 2010 under Ubuntu

At home, my desktop is far enough away from our wireless routers that I can’t use a wired connection. I meant to pick up a wireless card for it, but apparently forgot (go figure!). Coming home today, I realized my desktop doesn’t have an internet connection anymore because I ganked the wireless router I had setup as a client-bridge for the desktop so that I could use it somewhere else. Whoops! I’ll write up a post on using DD-WRT as a client-bridge for a wireless network if people are interested as well.

Come home, fire up the desktop, no internet. What’s the first thing that comes to mind? Yoink my parent’s wireless card from their desktop. It’s not like they use it right? My usage of the internet has to be far more important than theirs so I’ll just use this for a week. :P

Well, being an Asus Wireless USB card with the RT3070 chipset, I figured I’d just plug it in and everything would be hunky dory. Of course not. Yeah, maybe if I was using Windows, but if I was using Windows I’d spend 30% of my time scanning for viruses, another 20% of my time cleaning out all these leftover temporary files everywhere, and the rest of the time would be trying to fix the 0×02350 error codes the software I’m trying to get working so I can just turn in my freaking homework. Okay maybe it’s not that bad, but it sure feels like it sometimes. :P

As for the wireless card, I knew it was one of the most popular on Newegg so a few minutes of googling brought me across the following instructions that lead to a successful wireless connection!

vim /etc/udev/rules.d/network_drivers.rules
Put this line in the file:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1784", RUN+="/sbin/modprobe -qba rt2870sta"
Proofread carefully, save and close.

sudo vim /etc/modprobe.d/network_drivers.conf
Put this line in the file:
install rt2870sta /sbin/modprobe --ignore-install rt2870sta $CMDLINE_OPTS; /bin/echo "0b05 1784" > /sys/bus/usb/drivers/rt2870/new_id
Reboot!

Simple enough. What can I say, I love the Ubuntu community! Mad propz go out to chili555 and his post over here: http://ubuntuforums.org/showpost.php?p=9445731&postcount=58


Getting Started with Ubuntu, CodeBlocks, and GLUT

Posted October 29, 2010 under Ubuntu

One thing I’ve been doing lately is getting into a little OpenGL. I’ve been using GLUT in Code::Blocks and really don’t mind it at all. As your typical Vim user, I find IDE’s to be bloated, ugly, and just plain messy to work with. I figured being mainly a scripter, I was biased because most of the languages I use are filled with beautiful stack traces that allow for easy debugging.

It’s been a while since I went back to C++ and I always used Visual Studio for development (because that’s what the school uses). Sure, I should have fought the power and built GCC compatible binaries, but in the long run, it’s easier to just build it in the environment it’ll be tested on and worry about building good software in my free time.

Here’s the couple of steps I did to get started with Glut on Ubuntu 10.10:

  1. Installed the dependencies: build-essential, codeblocks, and freeglut3-dev
  2. I fired up Code::Blocks and created a new GLUT project.
  3. Choose the GCC compiler and when it asks you where GLUT is installed, just tell it /usr. All the headers should be located in /usr/include and libs in /usr/lib so that’s why you just tell it to use /usr.
  4. Compile and debug away!

Passwordless SSH on Ubuntu

Posted October 22, 2010 under Ubuntu

I’ve been working on quite a few computers on a small network lately (more details about that to come). This is a huge pain since I’ve only got 1 keyboard and mouse for the bunch. I’ve setup Synergy to make my life incredibly easier, but even still, it’s nice to be able to ssh into the other machines effortlessly. I also need passwordless SSH for some applications I’ll be running on them.

First off, you’ve got to install openssh-server on all of your machines. That’s really simple. “sudo apt-get install openssh-server”, done. Now you may want to allow any machine to ssh into the others, so you can use the rest of these steps on your own to accomplish that, but I’m making one machine the master node where it will be allowed to SSH into all of the rest, but only that one (for now).

Second step is to hop on the master node you designated and run “ssh keygen -t rsa”. Follow the instructions and have it save to the default location and tell it to not use a password. Make sure to keep your private key private. This is very important.

The last step is what lets you login to the other machines using that ssh key you just created. It’s really simple. “ssh-copy-id -i ~/.ssh/id_rsa.pub username@HOSTNAME.local”. Just replace the username and hostname and you’re done. Do this for each of your machines and now you can use ssh passwordless and painless.


« Older |