UNIX

Bash Completion

The Bash shell does tab completion executables, bash commands, and files/folders out of box. But it's completion can be extended to support even more types of completion including arguments for commands and things like hostnames through the use of programmable completion.

There is a package called bash-completion which includes a set of completions for various utilities. For example, for Subversion, if you type svn <tab><tab> (replacing with actually pressing tab) it will give you a list of all the svn subcommands that are available. If you type svn rev<tab> it will complete it to svn revert. For ssh, if you type ssh <tab><tab> it will list all the hostnames and IP addresses it knows about (it looks like it uses a combination of what's in /etc/hosts and ~/.ssh/known_hosts). You can of course do ssh username@<tab><tab> if you are using a specific username.

Once the bash-completion package is installed, you can copy additional completion scripts to /etc/bash_completion.d and they will be automatically included. I did this with the Maven 2.x completion script.

Git has a completion script that is included in its standard distribution. Find out where you have Git installed, and source the script <i>GIT_INSTALL_DIR</i>/contrib/completion/git-completion.bash in your .bash_profile. For example, I have Git installed via the binary installer for OS X Leopard, and thus I added this line to my .bash_profile:

source /usr/local/git/contrib/completion/git-completion.bash

Note that this is independent of the bash-completion package described above and does not require it (since we are sourcing it directly).

Django also has bash completion script included in its distribution. Replacing $DJANGO_DIR where you have the release extracted (or checked out from version control):

source $DJANGO_DIR/extra/django_bash_completion

With this, you get completion for django-admin.py and manage.py. For manage.py you need to set execute permissions and run it as ./manage.py on the command line rather than python manage.py in order to get completion for it.

Use rlwrap to wrap command line apps with readline

rlwrap wraps any command line utility with the GNU readline library, which gives you history and Emacs-style keyboard commands for line editing that you'd get with anything that uses the readline library (such as the Bash shell).

I started using it with Oracle's SQL*Plus command-line utility which lacks history and decent editing capabilities. rlwrap makes it much more pleasant to use.

There is a package for rlwrap in Ubuntu 9.04, so it is likely to be in other recent Linux distros. If you're on Mac OS X, Fink has a package for this. If you're on Windows, it looks like there is a package for Cygwin.

Emacs on Mac OS X

There are a couple of different options for Emacs on OS X. OS X comes with the text-mode version of Emacs (22.1.1 in Leopard). If you use the text-mode version frequently through Terminal.app, be sure to enable Terminal.app's "Use option as meta key." However, if you spend a lot of time in Emacs you'll probably want to use one of the GUI versions. There are a couple of options:

Aquamacs - An "Aqua-native" fork of Emacs that makes it work more like a Mac application. For example, it supports many of the typical Mac keyboard shortcuts and has tabs. From my brief usage of this, it looked very nice, but since I also use Linux and Windows (as well as text-mode Emacs on the Mac), I want my Emacs experience to be fairly consistent across all platforms.

Carbon Emacs - A Carbon port of Emacs (currently version 22). This is what I would have used if I couldn't get the Cocoa build to work.

GTK Emacs - This is available from Fink (currently version 22), but like all GTK apps built through Fink, uses X11. Using X11 apps on OS X is rather inconvenient, so I didn't bother trying this.

Emacs.app - A Cocoa port of Emacs. This code has been recently integrated into GNU Emacs for the upcoming version 23, but you have to build from the CVS source for that, which is what I chose to do.

The page for Emacs.app contains instructions for how to build from GNU Emacs CVS, but I'll describe the process here:

Incremental backups on Linux with rsync

Using rsync in combination with hard links, its very simple and easy to setup incremental backups in Linux (and UNIX). You end up with a full snapshot of each increment, accessible as if they were the original copy that was backed up.

wget -C option has been removed?

It looks like the wget option "-C off" (which disables caching) was removed recently. I didn't learn about this until one of my automated scripts (e-mails me IP address changes of my home machine) quit working (wget was returning an error). Now I am using the "--no-cache" option instead. I wonder how many people were affected by this change and why they even made such a change.

FreeNX server with NoMachine NX client is extremely fast

I was always impressed with Microsoft's RDP protocol and Remote desktop software because it was so fast that it felt like I was using a local machine. I use it to connect to my work machine to do work (rather than try to run things on one my home machines because it ends up being faster than that). I wished that there was something like that for Linux. I didn't particularly like using regular remote X, so VNC was my main option. I looked at NoMachine NX, but I didn't want to pay money for software I wasn't going to put serious use into. There is now a free NX server, called--you guessed it--"FreeNX."

I have not able to find an official home page for FreeNX, but I using this forum thread I was able to use this Debian repository to install it:
deb http://kanotix.com/files/debian/ ./
I also found this page which lists the following repositories but I did not use them:
deb http://archive.kalyxo.org/ staging main
deb http://archive.kalyxo.org/ experimental main

After I got things up and running (at first it didn't work, I had to enable the SSL Encryption option), I was very impressed by it. It's as fast if not faster than RDP (my upstream bandwidth on my cable connection is less than that of my work network, so its even more impressive). In full screen mode, it felt like I was using a local machine. Very cool. I will be using this more often, especially at home between my laptop and Linux box.
Syndicate content