Thursday, April 03, 2008

Command Line Bookmarks

I wish I'd known about this tool years ago. Today I discovered a little utility called cdargs. Basically it lets you browse your directory tree very quickly, and allows you to create bookmarks to your most often used directories.

The bookmarks are stored at ~.cdargs in a simple format that's easily edited whenever you want to modify them, but I'm getting ahead of myself now...

cdargs has a directory browsing tool which is invoked by the cv command. In this tool, you can use arrow keys, Vim bindings, or even Emac bindings to navigate. Pressing a on a directory in the browser adds it as a bookmark, and pressing Enter opens it back in the shell. To see more of the available commands, press H or ? in the browser.

Outside, back in the shell, you can copy files and move files to your bookmarked directories using the cpb and mvb commands respectively. For example, cpb foo bar will move the file called foo from the current directory to the directory that I have bookmarked as bar. You guessed it, cdb bar would change you to the directory bookmarked by bar as well.

This tool has several more features as well, but I'll leave those up to you to discover. The man page is a good read, and I don't want to take all the fun away from you :). The only problem I can see with this tool is that it may be difficult getting used to the different commands. Typically the commands they replace or supplement are used quite quickly. By the time I stop to recall the applicable cdargs command I've waited too long. If I can get past that, there's no doubt I'll get some good use out of this one.

Saturday, March 15, 2008

Change the Solaris Shell to Bash

For those of us that are stuck working in Solaris environments with either csh or ksh as the default shell, there is hope. Some of these environments have the chsh command to change shells, but for those that don't, here is how to change your shell to bash. First of all, make sure it is available on your system. It's typically found in /bin/bash. If it's there, you can edit your ~/.profile to make it run the new shell when you login.

IMPORTANT: Before doing this, open two separate shells. Keeping one open and unaltered is a good way to recover if something goes wrong in this process. If you break something and can't log in, you may piss off your system admin when you have to call him to fix it for you. Leave one of these open shells alone during this process.

In one of your open shells, add the following two lines to the bottom of your ~/.profile.

export SHELL=/bin/bash
exec $SHELL

You can now log out of that shell and back in again to see if it worked. If so, all went well and you can close the other shell. If not, use your "safety" shell to repair your ~/.profile so that you can log in again.

Sunday, February 24, 2008

Google Makes Me Stupid

Does anyone else find that sometimes their first response to a problem is to search Google? I just had the good ol' 500 Internal Server Error in an Apache request and immediately I searched Google for assistance. Given that the web server in question was my own, the reasonable person would first check the server error.log, but I'm apparently not that guy. In my defence, it didn't take long for me to remember this, but still, Google was my initial reaction.

A quick check of said log file suggested an .htaccess issue, and now all is well. Perhaps we're (I'm?) becoming too dependant on our search engine overlords...

Vim and Perforce

My employer has used Perforce as a VCS for several years now. Perforce itself maintains integration plugins for Eclipse, but of course not for editors like Vim so it's up to the community to do so. Lucky for me, extremely capable Vim scripters like Hari Krishna Dara also use Perforce from time to time :). This is the same author who brought us the genutils.vim plugin as well as many other powerful scripts as his vim profile lists. Among these is a fantastic perforce script set that I downloaded to try about a week ago. It was more than I'd hoped for.

This is a very featureful Perforce integration script with a complete set of menus (although I have menus hidden in my vim) and commands. I'm not sure whether the author still uses it or not however because there was a bug in spec-based commands that broke it pretty badly. Of course, there is the possibility that I'm using it incorrectly too. Regardless, I've "fixed" a couple of these bugs and emailed the author with a patch. I also uncovered a bug in the genutils.vim script that it depends on. The author also mentions this in the script page for the Perforce plugin:

Lately, I am not finding enough time to add features to this, so if anybody is
interested to help me add new features or even take over the responsibility, you
are very much welcome.

Although I sent him a small patch in his Inbox, he may not have the time to make a bug fix release, so I've made a little bazaar branch of the complete script on my own little server here for the time being. This branch includes the fixes for a couple of little bugs, and some extra syntax hinting for pending changelists and closed jobs. Aside from that, it's unaltered. You can get it using this command, assuming you have bzr installed.

$ bzr branch vim-perforce

I might add a few features or commands that have been included in the p4 client since his last release of the script at some point too. Depending on his email reply (if he replies) we'll see if he'd like my changes included in his next release or not. My additions unfortunately won't be of the same quality as the stuff he's already written. I'm not exactly a seasoned vim-scriptor...

All in all, it's a fantastic script. Check it out if you use Vim with the Perforce VCS, and big kudos and thanks go out to the original author!

Tuesday, February 19, 2008

Stumped by a Captcha

Does anyone see the security code in this captcha?

Bad Captcha Image

This one has me stumped...

Monday, February 18, 2008

GnuCash Broke My Ledger :(

For the past year and a bit, I've been happily using GnuCash with Ledger and it had been a fantastic duo. Several days ago, I upgraded to GnuCash 2.2.3 and the combo doesn't work so well anymore. The problem stems from an internal change that adds a "Root Account" as the top level account in the tree. To say the two don't work together anymore might be a little harsh, but they at least don't work as well together as they used to. For example, this used to work to get a quick net worth:

$ ledger bal ^ass ^liab

The ^ass and ^liab bits are regular expressions that match all accounts that start with the letters ass and liab (assets and liabilities) respectively. This would result in a little chart showing my total assets minus my total liabilities, since "Assets" and "Liabilities" used to be top level accounts. Now with the new structure, these accounts are no longer roots. Instead they look like "Root Account:Assets" and "Root Account:Liabilites". Long story short, this new "Root Account" is the only top level account. To make matters worse, the bloody account name has a space in its name, and we all know how well spaces work on the command line...

Needless to say, the combination became a lot less useful with this update. I'm not sure whether to downgrade to GnuCash 2.0 or not. What a shame.

Saturday, February 16, 2008

Changing the Default Text Editor in GNOME

The "Preferred Applications" menu item in GNOME runs a little app that allows you to change some of the default programs used for various tasks like web browsing, music playing etc. One thing that's been missing for me is the ability to change the default text editor. Sure you can open up Nautilus, right click on a text file, and chose that way, but there are many types of text files, and they are each treated independantly.

Recently I discovered the ~/.local/** path. I'll use gvim as an example for this excersise. This is the ticket for swapping default editors once and for all! First, use the method described above (the right click in Nautilus way). Now you should have a ~/.local/share/applications/gvim.desktop file. That's good. Next, create a ~/.local/share/applications/defaults.list file, and put this in it:

    [Default Applications]

The contents above were taken from my own system wide /usr/share/applications/defaults.list, just with :%s/gedit/gvim/. This should at least cover the file types that gedit keeps popping open for. You could always modify the system wide defaults.list, but be prepared to lose those changes during your next update. Also, since the gvim.desktop file already existed in my local home path, I never tried just copying the one from /usr/share/applications. That might work too.

I can't believe I've been using GNOME for so long and never knew this :(

Tiny Tiny RSS Feed Reader

Lately, I've been missing something in a feed reader. In the past six months or so I've tried a plethora of different readers of different forms. I tried the desktop application style like Lifrea, the online flavors like Google Reader, and the Firefox extension kind like Sage. All have their benefits, but also disadvantages. For example offline readers make it a pain when one uses different machines, online reader services felt slow or sluggish, and cluttered. Not to mention they can't be modified.

I forget now how I heard about Tiny Tiny RSS now, but if I remember I'll update this post with well deserved props. This thing is perfect in my opinion. It's fast, it's open source, it's written in PHP/MySQL, and it's pretty feature complete. Even setup was a breeze and went without a hitch.

The interface is very clean and well organized. One can tell pretty early that some of the interface ideas in TTRSS were inspired by Google's great GMail interface like the ability to star articles as well as the familiar actions list, and in fact it very much has the feel of using your typical desktop email application. This reader can run in either single or multi-user modes, and you can publish your feeds and articles with others with a single click.

I'll not provide a list of features here since they do a pretty good job of that on their website. If you are not in love with your current reader, I very strongly suggest this gem!

Sunday, January 20, 2008

It's Been Almost a Year

I'm about as interested in writing a reasons-for-not-posting-for-a-year blog entry as you are in reading one. Instead, I'll just say that since my last post I've gotten a job and I've gotten my wife pregnant.

The baby is due in May!

P.S. I really should take that terrible picture of my head down from up there...