Manoj Srivastava: Manoj: The Command Prompt
Or theming PS1
I am not fanatical about my command prompt. No sirree, not me.
It is just that I spend half my life either staring at an Emacs
window, or at an xterm command prompt; so even a marginal boost in
productivity goes a long way. And I am often logged in over ssh to
machines half a continent away, and am still comfortable enough on
the Linux VT to spend time there, and I often do not have the GUI
gew-gaws feeding me data. Hmm. Data. inpuuut. No. Must
focus.
With all these open xterms and Emacs terminal mode frames
floating around, it is easy to lose track of where I am on each
terminal, and what the working directory is. So I want my command
prompt to help me keep track of where I am. If the terminal is an
xterm, the title can be setup like
"user@host:../shotened/path/to/current/working/dir"I want to know what machine, id (am I root?), and directory I am in. If I am deep down in the labyrinths of some work related directory tree, I want the path to be pruned, from the left, one component at a time. However, this does not help me on the console; so I also want the path to be in the command prompt; but it should not take up too much of the command line; and ideally, should just go away as I type a longish command. Gawd, I love zsh. I once did a analysis of the command history. The most often used command sequences were
cd some-place, lsSo. pwd and ls. I really really want to see the directory listing when I change directory to a new one. As one grows old, memorizing the directory contents for dozens of machines all the time taxes the gray cells a bit. So, I figure, why not let the command prompt handle all that? Having the current working dir always visible cuts down a heck of a lot on the pwd commands, and so all that s left is to insist that the command prompt thingy always run ls after a change directory. Simple enough. Saves on typing. And time. And this is not just some crazy talk. I want help with noticing whether the previous command exited with an error status (useful for commands that normally do not create an output). If I am logged in to a machine on battery power, I want to know that. I also like visual cues to the amount of power remaining (good for my laptop on the long flights). I don t want to have to know f the machine uses APM or ACPI, I just want my prompt color to change as the power fades. I want my command prompt to let me know if I am in a directory which is under version control, and if so, what branch I am on. (I occasionally have to come in contact with arch, bzr, git, subversion, svk, and mercurial). If I am in a version controlled project, where I am relative to the root of the checked out tree is often more important than the absolute path, so I want to see relative paths, not absolute paths. I want to know if there are uncommitted files in the working directory. Visually. I want to be reminded if I am in the middle of an ongoing
rebase -i .This is not asking for too much, is it?
So, here is a screen-shot of this in action: I start from my
home directory, go to a directory not under version control, go to
a project under git, then a different project with uncommitted
files, and then finally to a subversion checkout. All with an angry
fruit salad of colors warrantied to make Martin Krafft want to claw
his eyes out
.
If you use zsh, then just grab hold of this, and then do:
autoload -U promptinit promptinit prompt manojThis might be a bit of a hit on slow machines, but even my laptop is a core 2 duo, so I do not find it noticeable. Oh, and if you liked this article, you might also like Theming Emacs, and Theming XTerms.
Categorized under:
- software::
Ever the sucker for punishment, I decided to pick three difficult things and stick them all together: LDAP, SSL and replication. Here's how to make it go on Debian and Ubuntu.
The problem
You want LDAP replication to happen over the internet, and you want it to happen securely.
The caveat
I'm not going to tell you how to set up your LDAP from scratch here: I'm assuming you've reached a solution you're happy with and want to replicate it.
The solution
We're going to set up a replicating slave LDAP server, which communicates with the master
over the internet via an SSL-protected connection.
Enabling replication
First up, the master LDAP server needs to be configured to permit replication.
The key lines to add to your 
Can't find any documentation about this on the web, and it's a PITA, so
here goes.
Note: No pictures. I was too scared to take time out to take pictures.
Disassembly is not hard at first. Three screws hidden over the battery pack
allow removing the cover over the power button and wireless switch, which
then frees 4 tabs that lock the top of the keyboard down.
My keyboard was also taped down with double-sided tape, and glued down.
This is the part I hate, both because I still haven't accepted that the
common way to put together consumer electorinics is tape and glue, and
because it's never possible to get it apart undamaged. I pried the keyboard
up from the top, pushing under to untape/glue, and taking care of the
cable. There was also a flap of plastic stuck down over the cable, which
had to be peeled away. Many clips on the bottom of the keyboard hold it in
place and have to be slipped out. I ended up slightly bending the arrow keys
of the keyboard in yanking it out, though I think they'd still be ok-ish.
Luckily I was putting in a new one.
Removing the keyboard cable was strange. Its socket is not the typical kind
you can life to unlock. The socket is one piece and does not move at all. I
eventually just pulled the cable out of it. This is where I started to get very
nervous.
Replacing the cable was a PITA. You have to bend its end at a 90 degree
angle, and then just line it up and press it down into the socket. Hard.
And rub along it and do whatever you can to get enough force exerted down
the thin cable strip to make it slip far enough into the socket to work.
I booted up the laptop several times while doing this, to test if I had
managed to get it working. Eventually I had.
Then I very carefully reseated the keyboard, and replaced the cover and
screws.
Unfortunatly, the tape and glue was doing something. The new keyboard is
very springy in the middle, where that held it down before. So I will have
to take it apart again and put on some new double-sided tape or something
eventually.
Conclusions:
Even though I ve dealt with
The
On the testing and unstable systems that i run, i occasionally get a disturbing "there are N newly obsolete packages" message. For example
Another year has past and 
(hint: D-I=Debian Installer, the installation system for your favourite distro)
Commenting on 
...that