Better GNOME Terminal Copy and Paste

In most programs these days, you press Ctrl+C to copy to the clipboard.

In GNOME Terminal on Linux it's Ctrl+Shift+C and in PuTTY on Windows it happens as soon as you select some text.

This was confusing me until I found a great feature of GNOME Terminal:
  1. Click on the Edit menu, then on Keyboard Shortcuts...
  2. Click on Copy, then type Ctrl+C

Now Ctrl+C will act as copy if some text is selected, but it still acts as the interrupt key to stop a program if there's nothing selected.

The GNOME Edit Keyboard Shortcuts menu



Ctrl+C with something highlighted



Ctrl+C with nothing highlighted

Labels: , ,

GNOME Without Borders

I run a lot of terminal sessions on my computer desktop so I can connect to some remote servers.

In GNOME, the terminal always starts out small, and then I have to click on the icon in the top right corner of the window to maximize it.

It also displays the title once in the title bar, and a second time in the tab title, which used up some of the screen unnecessarily.

No more!

The best solution I've found uses Openbox.

I installed it using Yum, then ran it once from the command line with the --replace option. After that, GNOME remembered to start it up instead of its default window manager, Metacity.

Then I created ~/.config/openbox/rc.xml with the following applications section:

<applications>
<application class="Firefox*">
<maximized>true</maximized>
<decor>no</decor>
</application>
<application class="Gnome-terminal">
<maximized>true</maximized>
<decor>no</decor>
</application>
<application class="Terminal">
<maximized>true</maximized>
<decor>no</decor>
</application>
</applications>


Now Firefox and my terminals start up maximized and without a title.


My GNOME desktop without window borders



On the rare occasion I need to turn borders back on, I can press Alt+Space then click on Decorate from the menu.

Labels: , ,

Disabling Ugly Fedora 9 Wallpaper

I installed Fedora 9 preview back in April.

This is what greets you when it's finished booting:



I think it's the ugliest login screen wallpaper I've ever seen, and the Fedora team don't give you any way to change it.

I tried deleting the package, but it kept coming back when I applied the latest updates.

Adding exclude=desktop-backgrounds* to /etc/yum.conf and running sudo rpm -e --nodeps desktop-backgrounds-basic seems to have done the trick.

Labels: , ,

Bold Shell Command like the Rails Books

I've recently been reading some books about Ruby on Rails.

One little thing that I thought was cool was the example commands:

dave> cd work
work> rails demo
create
create app/controllers
create app/helpers
create app/models
: : :


I decided to try to make my shell look the same.

Putting the directory name in the prompt is easy. That can be achieved by setting PS1='$(basename "$PWD")> '

(if you use zsh, you may need to run setopt promptsubst first)

Making everything you type after the prompt bold is the tricky bit. You have to enable bold mode at the end of the prompt, but disable it as soon as the user has pressed Enter, so the command's output isn't bold too.

This can be achieved in zsh by adding %{$(tput bold)%} to the end of your PS1 line, e.g.

PS1='$(basename "$PWD")> %{$(tput bold)%}'


and adding a function called preexec that resets the font to normal.

preexec()
{
tput rmso
}


And to finish up, I like to handle things properly if tput and basename aren't available, so I test if tput is present using command -V tput and use POSIX-style ${parameter##word} to delete everything except the last part of the path.

So the stuff you need to add to ~/.zshrc now looks like this
setopt promptsubst

init_terminal()
{
if command -V tput >/dev/null 2>&1; then
bold="$(tput bold)"
underline="$(tput smul)"
normal="$(tput sgr0)"
fi
}

last_part_of_path()
{
local full_path="$1"
local last_part="${full_path##*/}"

if test -n "$last_part"; then
echo "$last_part"
else
echo "/"
fi
}

preexec()
{
print -n "$normal"
}

init_terminal

PS1='$(last_part_of_path "$PWD")> %{$bold%}'


And the end result looks like this



Unfortunately, you can't do this in bash because it doesn't have an equivalent to the preexec function, so everything including the command's output will be bold. (There is a patch to add something similar, but it causes bash to crash in some situations, so I think it's safer not to use it.)

Labels: , , ,

MOTORAZR V6 on Telstra Next G

I got a new phone for work yesterday, a Motorola MOTORAZR maxx V6. It seems to be a pretty good phone. Much better than I was expecting.

When I last used a Motorola several years ago, the menus were less intuitive than the Ericsson or Nokia ones. Now I feel that both of those have taken a step or two backwards, and the Motorola is no worse. The menu hierarchy is quite logical, and the keypad is very direct and responsive. It's definitely better than my Sony Ericsson Z610i, which is especially good considering it's only about 1 cm thick.

I tried to get it synchronizing my contacts and calendar with Linux. Unfortunately, it's quite a new phone, so it's not supported yet. Instead, I set up an account on ScheduleWorld and transferred my contacts over the internet using a protocol called SyncML, which most new phones seem to support. It worked well and didn't cost me anything other than the data costs.

It's on the Telstra Next G network, which offers broadband internet access, and has much better coverage than the other 3G networks. The phone and network also support HSDPA, which is supposed to offer download speeds of up to 14 megabits (14,000 kilobits) per second. So far the best I've got is 400 kilobits per second, but that's still fast enuff to do my work. I'm connecting to it as a GPRS modem over Bluetooth so I can access the internet from my laptop.

So far so good!

Update: December 31, 2007


The phone stops making and receiving phone calls after a while. A reboot makes it work again. The dealer is sending it back to Motorola to get it fixed. (It's running software version R26111VL-AS_U_96.66.74R.)

Labels: , , , ,

Free Fonts

My interest in fonts began a few years ago when I discovered Lucida Sans. It was embedded in a paper about Plan 9, an operating system by the creators of UNIX. It's a nice, easy-to-read font without serifs (the ornaments on fonts like Times New Roman) that isn't as boring as Arial or Helvetica.

I was trying to find out how I could get the font on my computer, when I discovered that the Sun Java package includes the original Lucida Sans fonts. I now make a point of installing Java on all of my computers, then copying the fonts from the lib/fonts folder into my system fonts folder.

Lucida Grande



There's a similar font that comes with Mac OS X called Lucida Grande. If you're running Windows, you can get it by installing the Safari web browser public beta and copying the TTF files from the Safari.resources folder.

Microsoft Windows also comes with a version of Lucida Sans called Lucida Sans Unicode. On some systems (e.g. Windows 2000 without ClearType) this doesn't look very good and it doesn't differentiate between normal and bold, so I only use this as a fall back if the other two aren't available.

I use these three fonts as the default fonts on my web site. Since at least one of these is included in recent Windows and Mac systems, most peeple should see a Lucida Sans variant.

It also turns out there's a number of other good fonts available for free download, starting with the Microsoft Windows Core Fonts, including Andale Mono, Arial, MS Comic Sans, Courier New, Georgia, Impact, Tahoma, Times New Roman, Trebuchet MS, Webdings, and Verdana. Most peeple will be familiar with these fonts, but I'd like to point out Andale Mono as it's a really good font for programming and much better looking than Courier New. They can be downloaded from the SourceForge Core Fonts Project Page.

Andale Mono



Other worthwhile downloads are the Windows ClearType Fonts, including Calibri, Cambria, Candara, Consolas, Constantia, and Corbel. They are all included in a standard install of Windows Vista or Microsoft Office 2007, but you can also get them in the Microsoft PowerPoint 2007 Viewer package. Calibri is the definite highlight. It's the default font in Word 2007, so you're certain to see it more in future.

The Microsoft Office Fonts includes some classics, particularly Century Schoolbook, Gill Sans MT, and Lucida Sans. You can get them with most versions of Microsoft Office, but you can also get them in the freely available Microsoft Publisher 98 Euro Fonts Update. Run PubUpd.exe /c /t:c:\temp, then copy the TTF files from c:\temp into c:\windows\fonts.

I discovered today that Adobe Reader version 8 includes Myriad Pro. It's an attractive humanist font similar to Lucida Sans. It's the font used in Apple ads. You can download it here. Install it and then copy the OTF files from the Resource/Font folder into the system fonts folder.

Myriad Pro



Another set of good fonts that deserve more attention is the Bitstream Vera family. They are included as the default fonts in many recent Linux distributions, and can be downloaded from the GNOME Fonts web page. They can be used as pretty good replacements for Verdana, Georgia, and Andale Mono.

Thanks to GearedBull for releasing his excellent Wikipedia font previews into the public domain.

Labels: , , , , , ,