Posts tagged ‘linux’

  • Check what the clipboard contents are: xsel -b
  • Put foo in the primary X selection: echo foo | xsel -p
  • Copy the clipboard to the primary X selection: xsel -b | xsel -p

This is just a hint on how to copy/paste between X programs that cannot agree on which X buffer to use. Say you have the xterm which uses the primary selection, and you have some silly java program program which only uses the clipboard. What do you do if middle click doesn’t want to paste your console output.

An ugly workaround is to fire some editor that supports both and keep pasting with one method and copying with the other before pasting in the final destination. Middle click in gvim to paste what you selected in your xterm, then select the text in gvim and copy it to the clipboard.

Or, you can use xsel. The simple features of xsel are to put something in one of the selections (if there is anything coming on STDIN) or to output the content of a buffer. So, to put the primary (the one you get when you select text in X) in the clipboard (what editors put their stuff in when you do Ctrl+C) you can do xsel -p | xsel -b.

The efont family displayed in xfontsel

Finally! A set of fonts that look good and properly display Japanese and Cyrillic. That is, the Cyrillic is half-width as it is supposed to be. For Gentoo users the package is media-fonts/efont-unicode or there is the official page for everyone else. Some characters like the lowercase б and д are oddly designed but that’s a very small price to pay for the pleasure of not having to mix and match different fonts in my terminal configuration.

I wish I’d known that a little earlier.

When trying to install grub2 (whatever snapshot was current as of today) I kept getting the following error:

$ sudo /sbin/grub-setup -v --directory=/media/sysrescd/boot/grub \
  --device-map=/media/sysrescd/boot/grub/device.map -r '(hd1,1)' '(hd1)'
.... snip ...
grub-setup: error: Cannot read `/media/sysrescd/boot/grub/core.img' correctly

The error was not very descriptive because grub was apparently able to read other important files like boot.img and such. The filesystem on my USB stick was identical (feature wise) to the /boot on my HDD — ext2. And the same command worked just fine for installing to my hard disk.

Digging through the code revealed where the problem is. The error was caused by grub-setup being unable to embed core.img in the MBR. The core.img prepared by grub-mkimage was 25k big. That is about 50 sectors. The first partition on my hard disk starts on sector 63. The first partition on my USB stick was starting on sector 32 (or was it 31?). 32 < 50 => core.img cannot be embedded. If only the error message had been a little clearer it would have saved me some headache.

Destroying the first partition on the USB stick and recreating it starting from sector 63 fixed the problem.

Edit the svn:externals property for the directory where the external stuff will go into
svn propedit svn:externals .

Add a line for each external entry you want to have:
local/path http://external/repo
local/path2 -r### http://external/repo

Example for me adding jokey’s virtualbox ebuilds:

svn pe svn:externals /var/repos/chutz/app-emulation

virtualbox http://overlays.gentoo.org/svn/dev/jokey/trunk/app-emulation/virtualbox
virtualbox-additions http://overlays.gentoo.org/svn/dev/jokey/trunk/app-emulation/virtualbox-additions
virtualbox-bin http://overlays.gentoo.org/svn/dev/jokey/trunk/app-emulation/virtualbox-bin
virtualbox-guest-additions http://overlays.gentoo.org/svn/dev/jokey/trunk/app-emulation/virtualbox-guest-additions
virtualbox-modules http://overlays.gentoo.org/svn/dev/jokey/trunk/app-emulation/virtualbox-modules

The original tip was here.

Mutt is my mail client of choice. The reasons are simple: It…

  • is fast
  • is usable from the command line (a big plus)
  • lets you do essentially anything to a message
  • supports hooks for very flexible configuraiton

And the tip of the day — how to fix unreadable (as in — mojibake mail) to be readable again.

  1. Highlight the mail in the index and press “e”. This will fire up your editor (vim in my case) and load the full mail in it.
  2. Find the “Content-Type” header. Edit the value of the “charset” field on the line. If there is no such header just add one:
    Content-Type: text/plain; charset="iso-2022-jp"

If the subject of the mail is also unreadable, do the following:

  1. Install maildrop
  2. Select the Subject line and pass it to this command cat | xargs -ifoo reformime -h "foo" | iconv -f iso-2022-jp -t utf8 | xargs -ibar reformime -o "bar" -c utf8. In vim speak, this means
    1. /^\csubject:
    2. Shift-V!cat | xargs -ifoo …
  3. Play around with the charsets if you’re not getting correct results.