custom command prompt

Published January 22nd, 2010 by Chad

I spend a lot of time in the terminal and at the command prompt. The default prompt for Ubuntu is very…unhelpful, to say the least. I already know who I am and most of the time I know what machine I am on. So after talking to a friend of mine and doing a little research I have come up with this custom command prompt that suits me just fine.

custom command prompt screenshot

custom command prompt screenshot

The first part is the time that the prompt was given. This idea came from my friend. I like it for things like figuring out just how long that last command took (without having to run it again with the time command) and for simply seeing what time it is (since I am in the terminal a lot).

The next part is the current directory I am working in. I made it a different color to make it stand out a bit more from the rest of the stuff on the screen. So, with a quick glance, I can determine if I am in the right place before running the command.

The last part is the coolest (in my opinion) by far. I found an example of the smiley faces being used and really liked that idea. Once again at a glance I can determine something important. This time, I can determine whether or not the last command was successful. If I see red, I can look back and see what happened. If no red, keep going, everything is just fine. Pretty cool.

Now to the nitty gritty. How exactly do you create a custom prompt like this. After ripping things from a few different places (and doing a lot of my own troubleshooting) I came up with this for my custom command prompt: PS1="[\e[00m][\T] [\e[1;34m]\w `if [ \$? = 0 ]; then echo -e '[\e[01;32m]:)'; else echo -e '[\e[01;31m]:('; fi` [\033[00m]\$[\e[00m] "

Confused? :) I was too. In fact, I am still unsure as to what exactly some of it does. Oh well.

The segments that look like [e[00m] (sometimes with different numbers) are specifying the colors of the different sections. The first part you can see that after the color specification section there is a [\T]. This simply specifies that the current time (\T) needs to be printed between some square brackets ([]).

Next there are some more colors specified followed by \w. This specifies that I want the current working directory displayed. A capital W will display the current working directory without the path.

Then comes the fun stuff. Bash scripting within a string! Basically it says that if the last command was all good, display a smiley face. However, if something went wrong, a frowning face is displayed (in red). The bash scripting is just a simple if-else statement with some echo calls.

The key here is making sure everything is escaped correctly. Add a comment if you have any questions. BTW, here is another good reference for this type of thing.

synergy

Published December 15th, 2009 by Chad

Let me start off by just giving you a really good link for what I am about to talk about. Ready? SynergyHowto. There, now lets begin.

At work I have two computers working for me; a desktop (with a 30in monitor!) and a laptop. I place my laptop next to my monitor on my desk so that I can easily see and access it if I need to.

As you can imaging, I started to get really annoyed at having to move my hands and arms from one keyboard/mouse to the next to use both computers. What if I could just the same keyboard and mouse for both computers? Enter Synergy.

Put simply synergy is a keyboard and mouse sharing system. Synergy has both a client and a server application. The server is installed on the system that you want to share your mouse and keyboard from. The clients are installed on any other number of computers that you would like to control with that same keyboard and mouse. The only requirement is that the systems be on the same network. Easy.

The setup takes a little (and I mean little) work. You must state in the config file which computer is the server and which are the clients. Also you must specify where each computer is with respect to each other computer. For example, in my setup my 30in sits right in front of me and my laptop sits to the right. In my config file I specify that the desktop is left of the laptop and that the laptop is right of the desktop. At first this seemed a little redundant, but it works so I can’t complain.

Anyway, if you have a situation like this, were you would like to control more than one computer with one mouse and one keyboard, give synergy a try.

By the way, on Ubuntu 9.10 (and I believe in older versions) you can just install it by typing the following (this will install synergys (synergy server) and synergyc (synergy client): sudo apt-get install synergy

changing gnome-terminal default window size

Published December 8th, 2009 by Chad

I actually like the default window size for the gnome-terminal in Ubuntu now. But I used to not like it. There was a time when I would run a command, see that the output of the command wasn’t displayed nicely, resize the window manually, and rerun the command. Annoying. If you would like to change the default gnome-terminal window size just follow these steps.

  • Open terminal window.
  • Type: sudo gedit /usr/share/vte/termcap/xterm
  • Find the following line: :co#80:it#8:li#24:\
  • Change to your desired window size (the number after :co is the number of columns and the number after :li is for the number of lines): :co#200:it#8:li#50:\
  • Save and close the file.

Every gnome-terminal you open now with use this new window size as the default. This will only work after you have closed all of the opened gnome-terminal windows first. Enjoy.

custom date and time in panel

Published December 3rd, 2009 by Chad

As you may have noticed by the screenshot from my last post the date and time portion of my panel isn’t the norm. Thanks to one of my new favorite sites OMG Ubuntu (not a fan of the name, but what are you going to do, right?) I was able to easily customize this portion that used to take up so much of my panels real estate.

This post, Some More Gnome Panel Clock Applet Styles, from OMG’s site gives you everything you need to know to make the changes. I will not repeat the steps here.

karmic recap

Published December 3rd, 2009 by Chad

My, my, my how the time flies by. :)

Well its been a while since I first downloaded and installed Ubuntu 9.10 (Karmic Koala) on my work laptop (64 bit). I have to say, it has been fun. I just love it when stuff works. I started off the whole process with a home directory backup. I have a 500 GB external HD that I just copied my whole home directory straight over to. It took quite a bit of time, but then I had everything safely stored in another location so I could completely wipe the HD in the laptop and install a 64 bit OS (previously I was running Ubuntu 9.04 32 bit). The install went fast (from a CD about half an hour) and then I was up and running. The ATI card in the laptop was already supported (no need to install a third party driver to get compiz to work) and within an hour I had everything I needed to get the work I needed to do done. A nice chunk of that hour was spent trying to customize and figure out empathy (the new default IM client for Karmic replacing Pidgin). After that I decided I just needed to install Pidgin for my IM client and everything else went smoothly. I have tried using the new software center a few times now to discover new software that I might like to install. It is great for just that, but don’t try installing anything from it. I don’t know if it is just me it not but it seems to take forever to install anything through that application. I have also done a lot of customizing with the humanity icons in my panel. These are the one color icons that showed up in Karmic. For example my last post shows some of the Pidgin icons I made to look more like the theme. I have since used most of the custom icons posted on OMG Ubuntu.

My work laptop running Ubuntu 9.10

My work laptop running Ubuntu 9.10