Monday, June 30, 2014

Vim: Meta Toggle

Usually you want to have your terminal setup the way that Alt/Meta sequence sends escape sequence as oppose to set character's 8th bit (which conflicts with UTF-8). If that's so, using Meta key-bindings in terminal applications becomes a bit of challenge. One approach is to not use such key-bindings at all, other is to tackle the problem of recognizing plain Esc key and escape sequence with timeouts. If application sees Esc followed by a character very quickly then it is safe to assume it is escape sequence. On the other hand if there is a significant pause it's probably a separate Esc key followed by a character key. Every application has it's own way how to deal (or not) with this.

Vim: Zoom / Restore Window

" {{{ Zoom / Restore window

function! s:ZoomToggle() abort
    if exists('t:zoomed') && t:zoomed
        exec t:zoom_winrestcmd
        let t:zoomed = 0
    else
        let t:zoom_winrestcmd = winrestcmd()
        resize
        vertical resize
        let t:zoomed = 1
    endif
endfunction

command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <M-z> :ZoomToggle<CR>
nnoremap <silent> <M-m> :ZoomToggle<CR>

}}}

Vim: Walk Through List of Colorschemes

Do you have a couple of favourite Vim colorschemes you frequently switch in-between? You can assign key binding to each one of them, but if you have more and prefer scrolling interface here is a simple one.

Get & Set terminal ANSI colors

Recently I've hacked a couple of small tools to help manage terminal colors.

  • tcolors - get / set terminal ANSI colors (palette, foreground, background, cursor)
  • tcolors-gtk - simple GTK interface for tcolors
  • tcolorsinfo - test terminal ANSI colors
  • tcolorsinfo8 - tcolorsinfo wrapper for quick test of base 8 colors

Check out the source.

libaosd with Xinerama and More

I was using libaosd for a simple OSD style notification for years. Then lately I though I should fix some of its annoyances. So I've added Xinerama support and couple of 'aosd_cat' features. Check out the source.

Manage Lenovo Ultrabay

I have a Lenovo laptop which features an Ultrabay. By default it contains DVD drive, but that one can be replaced with an extra battery or 2nd HDD in special enclosure. I've did just that and put DVD drive into external USB enclosure. Now I can have a 2nd hard-drive and since SATA supports hotplug I can pretty quickly dock/undock it and exchange in case of a need.

Sunday, June 29, 2014

Unmount All

The task is to unmount all the mountpoints of a specified block device, such that we can e.g., remove it from the system. However, unmounting filesystems in question and disassembling a chain consisting of several devices (crypt, lvm, raid, etc.) has to be done in correct order which makes the whole process complex and prone to errors if done manually.

Patching tmux(1)

Using tmux, you might have noticed that when running an application like 'ranger' you will get your window named as 'python'. That's not really descriptive, so I've looked if I can get the real name into my 'tmux' statusbar.