mntnoe.com

Tips and tweaks making you more efficient with your favorite Linux tools.

Many sites (for instance aula.au.dk) sends binary files using the application/octet-stream mime type. This is annoying for Firefox users, as they presented with a dialog asking Would you like to save this file? instead of showing the standard dialog offering both the options Open with and Save file.

Bug 327323 has a patch that uses gvfs to determine the mime type from the extension if Firefox cannot determine it itself. However, if you can’t wait for that fix to reach your distributions package repository, here is a patch for Firefox 3.5 that bypasses the security restriction for octet-streams and executables. Note that it won’t remember the application you specify to handle the file, but your can circumvent that by using the OpenDownload add-on, which uses your native mime system to look up the default application.

Edit: I found out that OpenDownload also alters the security restricted download dialog, so you can suffice to install OpenDownload if you want to avoid patching Firefox. You will only be able to open the file with your OS’ default handler, though.

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

GMail has a nice keyboard accelerated web interface making it competitive to desktop mail clients as Thunderbird and even Mutt. One reason I stayed with Mutt for a long time was the ability to integrate with Vim. I switched to GMail’s web interface for other reasons, but nevertheless it was delightful to discover ItsAllText; a Firefox add-on that allows you to edit any textarea in an external editor. continue reading…

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

As you can see I have polished my blog a little, and added a very important feature: A blog focusing this much on key bindings must naturally have keybindings. Using this plugin, you can now zap back and forth between posts by pressing Shift-Left and Shift-Right – useful huh? :-)

By the way, see Vito Chin’s article about Keyboard Enabling Web Applications.

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

Wouldn’t it be nice if you could navigate through your application’s menus using vi-like bindings? You can! Simply something like this in your ~/.gtkrc-2.0 file:

binding "gtk-binding-menu" {
    bind "j" { "move-current" (next) }
    bind "k" { "move-current" (prev) }
    bind "h" { "move-current" (parent) }
    bind "l" { "move-current" (child) }
}
class "GtkMenuShell" binding "gtk-binding-menu"

Keybindings for other GTK widgets can be defined in a similar way. What about moving focus between widgets in the direction they appear? continue reading…

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

When using Windows XP at work, I have customized the keyboard layout to almost match my setup on Gentoo — important when you code lines and lines of Java…

In addition to my modified Colemak keyboard layout created by the Microsoft Keyboard Layout Creater, I use scancodes to remap special keys, which is not possible in MKLC.

My current setup is this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,08,00,00,00,01,00,3a,00,3a,00,01,00,19,00,46,00,0e,00,19,00,2a,00,56,00,38,00,38,e0,38,e0,2a,00,00,00,00,00

Note: Be careful when pasting stuff like this into your registry — you have been warned :-)

The scancode mapping does the following:

  • Swaps Escape and Caps Lock.
  • Makes QWERTY P an extra Backspace key.
    Remember, Colemak has the semicolon on QWERTY P’s position. This makes it possible to delete
  • Makes P available on Scroll Lock.
    A pragmatic backup key for P when using other layouts than Colemak. For instance, some virtual machines read raw input from the keyboard, but the scancode map still applies.
  • Moves Left Shift to Less Than (at the right of Left Shift on pc-105 keyboards).
    This eases the strain on the left little finger.
  • Copies Left Alt to Alt-Gr.
    This way, you can use both hands for the Alt modifier, which greatly reduces the strain on the hands. Generally, use the one hand for the key and the other hand for the modifier.
  • Moves Alt-Gr to the original position of Left Shift.
    Takes a little to get used to, but very handy when defining custom keybindings.

The format of the scancode map is pretty simple:

00,00,00,00, <- preamble
00,00,00,00,
08,00,00,00, <- number of remaining 4-tuples (end-sequence inclusive)
01,00,3a,00, <- swap Escape and Caps Lock
3a,00,01,00,
...
00,00,00,00  <- end-sequence

You can find more information on the scancode map format here, and a scan code reference here. Have fun…

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

Rival blog

No comments

My just-as-tool-minded friend has created a blog at esbena.blogspot.com, which you might be interested in. He has some nice setup for Emacs and Eclipse, and is the creator of screencast-mode. Oh, and getting a new rival blog made me put myself together and update my blog :-)

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

One of the most useful features in Zsh is its support for user-defined widgets. These two commands will greatly speed up your directory navigation in Zsh:

setopt autopushd

go-up () {
cd ..
zle reset-prompt
}; zle -N go-up

go-to-previous () {
popd
zle reset-prompt
}; zle -N go-to-previous

bindkey '^[u' go-up
bindkey '^[p' go-to-previous

Now you can go up one level with Alt-U and go backwards in history with Alt-P. Also, this won't clutter your terminal with "cd .." lines, as the prompt line gets automagically updated. Similarly, you can add bookmark-like functionality with something like this:

typeset -Ag bookmark

bookmark[1]="$HOME/work/project"
bookmark[2]="$HOME/work/project/src/foo/bar"
bookmark[3]="$HOME/work/project/test/foo/bar"
bookmark[4]="..."
bookmark[5]="..."
bookmark[6]="..."
bookmark[7]="..."
bookmark[8]="..."
bookmark[9]="..."
bookmark[0]="..."

go-to-bookmark () {
cd $bookmark[$KEYS[-1]]
zle reset-prompt
}; zle -N go-to-bookmark

bindkey '^[0' go-to-bookmark
bindkey '^[1' go-to-bookmark
bindkey '^[2' go-to-bookmark
bindkey '^[3' go-to-bookmark
bindkey '^[4' go-to-bookmark
bindkey '^[5' go-to-bookmark
bindkey '^[6' go-to-bookmark
bindkey '^[7' go-to-bookmark
bindkey '^[8' go-to-bookmark
bindkey '^[9' go-to-bookmark

Have fun!

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

I have been using XMonad for about a year now and have finally put myself together to upload my customizations. Highlights:

  • Labeled pager addon for DynamicLog
  • Fast navigation between workspaces
  • Application specific border colors
  • Modified Scratchpad using GNU Screen
  • Host specific settings (layouts and widgets)

To use these modules, you must put them in ~/.xmonad and then reenable support for user modules in your xmonad source. Simply look for a line in Core.hs containing runProces “ghc” ["--make", "xmonad.hs" ...] and remove the “-i” entry from the list. This switch was unfortunately added to fix a bug on case insensitive file systems. Note that a solution is under development, placing user modules in ~/.xmonad/lib, thus solving the issue with case insensitive systems, see issue 230.

xmonad-mntnoe_2009-07-18

I will try to make some darcs patches for xmonad-contrib if I get time. Until then, I hope you can get inspired by some of my ideas. Enjoy :-)

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

I like to be able to find the next occurence of a string without exiting the command line. Here is a hack to do that:

set incsearch
cnoremap <expr> / (getcmdtype() == '/' \|\| getcmdtype() == '?' ? (getcmdline() == '' ? "\<Up>" : "\<Cr>/\<Up>") : "/")
cnoremap <expr> ? (getcmdtype() == '/' \|\| getcmdtype() == '?' ? (getcmdline() == '' ? "\<Up>" : "\<Cr>?\<Up>") : "?")
  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

Here is my Vim configuration as of May 2009. It is a work in progress (and will always be), and is designed on a number of pragmatical choices and compromises, rather than on a universal guideline.

That been said, I think my configuration has become pretty neat. See for yourself :-)

I only use Vim in the terminal, but most of the configuration also works in gVim (you may have to modify some of the bindings for the special characters like <C-Space>).

Although the .vimrc is long, I have tried to avoid making the configuration too heavy, so you will only find mappings that I actually use. Usually, I discover a work pattern that I want to speed up, and create a binding. Then I try it some time to see if I will get used to it; if not, I remove again. That’s the methodology :-)

Major features

  • Usable with both the Colemak and Qwerty layout
  • Readable colorscheme
  • Makes heavy use of alt/meta bindings (as alt is easier to hit than control)
  • Efficient tabbed navigation
  • Custom status line
  • Quick access to often used Ex commands
  • Many navigation improving bindings (examples: next occurence of visual selection, tag jump in new tab reusing existing tabs, search outline ({{{), open visual selection in split window)
  • Plugins are configured to be pervasive (they will not get in your way; at least not my way :-) )

As of writing, I use these external plugins, which you may download from vim.org.

  • AlignPlugin
  • NERD_commenter
  • a (alternate)
  • imaps
  • matchit
  • project
  • rhs (not yet published)
  • securemodelines
  • surround
  • taglist
  • timestamp
  • vcssvn

Of “major” filetype plugins, I use haskellmode and latexsuite.

These are the files of interest. Enjoy :-)

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon