Zsh and Its Searchable History

So I guess this says a lot about me and the limited things I do on my Linux box as well as the power of ZSH’s searchable history, but I find myself rarely typing commands from scratch. Instead typing the first few letters of the command then using the up cursor arrow to search for the last time I ran that command. It is so, so useful. Rarely do I need to grep my way through my .history file. For commands such a checking a Duplicity backup to Backblaze’s B2 buckets, where I need long strings of my keys it is essential. But for even simple commands like updating my Gentoo setup it is just so useful.

Can you remember this every time?
Duplicity collection-status b2:// [22 character string]:[22 character string]@BucketName/folder

I should remember this one, but I never remember those parameters…

Emerge -uDNav @world —keep going

For bash that was:
history | grep xxxx
– Then typing the line number.
– Hitting ctrl-c to kill that command
– up cursor key then editing the command before hitting return.

With ZSH I type the first few characters and then the cursor. Even when you search and use the line number it allows you to edit that command before running it.

By default this behaviour is not enabled. But edit your .zshrc/.zprofile files and bind the UP/DOWN cursor keys to these two options:
bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward

Oh and if you use zsh (it’s the default shell on macOS nowadays) then you really should use Oh My Zsh

Tapbots Tweetbot Memorial

Tapbots called it a day on their Twitter client Tweetbot. All quite sad really, but I guess inevitable. After I stopped using Tweetdeck, Tweetbot became my favourite Twitter client both on macOS and iOS. It was just so easy to swap between accounts and to tweet as a different accounts without switching accounts.
I got onto the beta of their new Mastodon client for iOS, Ivory, a week or so ago. I’ve just bought an annual subscription.

The Shit Show

Craig Hockenberry’s blog post about the last day of Twitteriffic working is acerbic and brilliant. It’s all because of Space Karen’s blocking of most popular third party Twitter clients from their API. I never used Twitteriffic. I used the web client, then Tweetdeck and finally settling on Tapbots set of iOS/macOS clients (which have also stopped working).
Since the buyout I’ve more or less stopped using my personal account. I’m reluctant to delete it as it’s been active since 2006, but it’s not been much fun over the past few years. I have kept three other accounts active. My work account, a campaign account and a village news account. I should let these die too really.
I opened a Mastodon account when Space Karen first hinted he wanted to buy Twitter (thanks Raj!) but never really used it. But since November I have. A much pleasanter place.
So far I’ve been using an iOS Mastodon app, Metatext, on iOS and macOS (Apple Silicon right!). Luckily Tapbots are working on an iOS Mastodon client, that I managed to get on the latest round of TestFlight beta apps yesterday.
Note: I’m posting this in an attempt to revive my blog. Instead of Marsedit (my usual blogging tool) I’m using Drafts with the WordPress Action.

Restoring C-A-backspace to Xorg server

Recent versions of Xorg have removed the old stalwart key combination of pressing CTRL-ALT-BKSPACE to kill the X server. I’m not sure why this was removed. I can only guess that such a drastic way of exiting your X session, without of course asking if you need to save any of your documents, was regarded as a non-desktop way of doing things. Although I like this key combo I can see this reasoning only too well.

If, like me, you like this behaviour to be restored then there are a few ways of doing so.

  • If you use .xinitrc or .xsession to manage your X session, then simply run this command from there:

    setxkbmap -option terminate:ctrl_alt_bksp

    On Gentoo (the distro I use) you’ll need to emerge the following package:

    x11-apps/setxkbmap
  • If you use HAL to manage input devices, copy the following few lines into the fdi file from /etc/hal/fdi/policy/ which you use to control your keyboard.

    Incidentally HAL was deprecated as of x.org 1.8 in favour of udev. So if your distro uses Xorg.18 or higher you’ll need to find a different way

     <merge key="input.xkb.options" type="string">terminate:ctrl_alt_bksp</merge> 

    (If you do not have any custom keyboard rules, you can copy and adapt rules from /usr/share/hal/fdi/policy/10osvendor/10-x11-input.fdi)

  • Finally you can edit xorg.conf with the following code to your keyboard’s InputDevice section :

     Option "XkbOptions" "terminate:ctrl_alt_bksp".

    

  •  

     

    messing up .htaccess in WordPress

    If you change a hard link in WordPress it appears to edit your “.htaccess” file to fix it.

    I’d had some custom lines to use php5 instead of php4. These got removed and my website stopped working.

    Simple-Tweet is php5 only and this brought the whole lot down.

    Impressed by the write speed on my new ReadyNas Pro 6

    A 100GB file to a NFS mounted share

    scotgate mnt # dd if=/dev/zero of=/mnt/distfiles2/TEMP bs=1024 count=100000000
    100000000+0 records in
    100000000+0 records out
    102400000000 bytes (102 GB) copied, 1115.25 s, 91.8 MB/s
    
    scotgate mnt # dd of=/dev/zero if=/mnt/distfiles2/TEMP bs=1024 count=100000000
    100000000+0 records in
    100000000+0 records out
    102400000000 bytes (102 GB) copied, 1076.49 s, 95.1 MB/s
    scotgate mnt # 

    That’s quite tidy!

    removing a file extension from a bunch of files

    During my Ph.D. I used a VMS machine with GCG a great deal. Not a powerful machine by any stretch of the definition but it was there, accessible and had a copy of GCG with updated databases.

    VMS has more than a few differences when compared to UNIX. A great feature is filesystem level versioning.All save operations will create a new version. Edit a file called “mess” and upon saving you will now have “mess;0” and “mess;1”. Edit it a subsequent time and you have “mess;2” and so on. This is a great way to fix a problem if you messed up editing it, Although having all those files in a directory does get a little annoying. I guess that the shell allowed you to only display the most current revision of a file but I never got around to finding how!

    Anyway I recently had cause to revisit a bunch of sequences from my Ph.D. days and had to get rid of the extension of a whole bunch of files (a few thousand). Performing rename operations under UNIX is always a pain in the arse. Linux has the rename command which makes this easier (remember rename is just a mv), but I was doing this from OS X which has no such command. Normally when I come across such a missing app under OS X I’d use Fink to compile and install a missing command, but it seems there’s no package for it.

    Basically I needed to do the following operation on many files:

    mv './INTERESTING.LIST;4' './INTERESTING.LIST'

    However that ;4 could be any digit from ;0 to ;10 depending how many times I’d edited the sequence under VMS.

    For such renaming operations I would use ‘find’ and ‘xargs’, however, for the life of me I could not get it to work.

    In the end I settled for the following command. It’s quite an elegant solution as it uses echo to send the substituted command through sed to remove the version number from the second iteration of the found file, and then pipe this through to the shell to execute it..

    find . -name "*;4" -exec echo "mv '{}' '{}'" \;

    sed 's/\;4//2'

    The full command is:

    find . -name "*;2" -exec echo "mv '{}' '{}'" \;| sed 's/\;2//2' | /bin/sh

    I found this in a post on the Macworld Forums.

    Of course if I had have been clever I’d have run this in a shell loop to perform for each digit. However, I’d wasted too much time as it is and I just ran the command ten times.

    Technorati Tags:

    Problems uploading images to 1and1 hosts : Server error 500

    I’ve had lots of problems with a 1and1 WordPress installation and uploading images within Marsedit.

    Generally the image was uploaded correctly to the correct location on the host but gave a “Server Error 500” error message. This meant that Marsedit did not insert the link of the image and neither did it show in the Published Images Media Manager

    There’s a quick workaround where I manually added the code to insert the image into the blog post. However, whereas the ability to write raw HTML is always handy, in this case it prevented me from finding a proper fix. I think I’ve had this problem for like a year. What a lazy sod!

    The proper fix is to ensure that PHP is properly setup. Which is hard when you have little control over the host. So a quick fix is to add some lines for handling PHP script execution to your .htaccess file.

    AddType x-mapp-php5 .php
    AddHandler x-mapp-php5 .php

    – Download that file from your WordPress installation, if it exists.

    – Add those line

    – Upload the modified file.

    Note you may need to change your FTP client’s settings to ensure you see dot/hidden files.

    I came across this fix on the wordpress forums.

    Technorati Tags:
    ,

    New mythtv frontend setup

    I’ve just setup a new Mythtv box. Although the previous system was relatively quiet, it was in a big box, and I want minimalism now rather then obvious geekery in the living room.

    So I’ve got myself an Acer Revo r6310, found at a cracking price on the superb UK Hot Deals. This is a Nvidia ION dual core Intel Atom powered beasty. The old Mythtv box is now up in the loft.

    I was going to try out one of the Mythbuntu releases. But it took ages to download, so I ended up putting a Gentoo minimal installer on a bootable USB stick and went from there. After setting up distcc on my main Linux box (also 64bit) the compilation took about 36 hours.

    Using VDPAU with the binary Nvidia drivers. playback is awesome. So far the largest 1080p sample I have (The trailer for Alexander) plays perfectly. Although I seem to be unable to get WMV audio to play.

    Video output is via the HDMI > DVI and audio is purely via SPDIF to the amplifier.

    Very pleased so far.