# Housed In

## Tearing and Knocking

It is somewhat summer-ish again in Dublin, so it's back to work on the house.

Started tearing down more wallpaper along the corridor over the Easter long-weekend break, and as usual, there's plenty of damage hidden behind those wallpaper. The worst one uncovered was a wall beside the door that wasn't actually concrete, but a wood scaffold that's been screwed up to hold the door itself assembled. That's some terrible job the tradespeople here have done… and reinforces the perception that you can't rely on the local tradespeople to do things right.

Anyhow, it seems likely that this going to spiral into another time-sink than I would have liked. At the moment, things are also compounded by the situation where the DIY stores have been swamped with orders since nobody can head out, as everybody is thinking of doing some DIY while they are stuck in.

Hopefully the situation will easy a little by mid-May.

I was trying to remember bash's readline configuration since a while, and have never been able to be fully committed in understanding its modality, and to figure out why certain keystrokes does not work in some MacOS for some reason.

The main 2 issues I had was not being able to navigate forwards/backwards by word that works in Linux using alt-f and alt-b, but never seems to work in MacOS. So with the recent experiments, I came to conclude that MacOS intercepts the alt keys altogether to prevent the bindings from ever working.

I was hoping to rebind the keys to ctrl but with the ‘hjkl’ keys as with vim's navigation nmemonic, but they collide with existing ctrl-h: backspace, ctrl-j fasd history-autocomplete, ctrl-k: kill line, ctrl-l: refresh terminal operations.

Going through the manual, and parsing a few of the hard-to-understand paragraphs and experimenting, I realise that it's possible to ‘meta-ify’ alt keystrokes, ie substitute the alt key, by pressing esc and then the desired key rapidly after (the emacs way? … Come to think of it, that's unsurprising, given this would be the GNU/Richard Stallman era). The way it was written, was just archaic and confusing - I've only comprehended the phrasing well after modifying my configuration to accomplish what I wanted using ctrl keybindings.

Anyhow, the configuration that governs bash's general behaviour for keystrokes (and as well as any other TUI applications that uses the readline library), is stored in \$HOME/.inputrc. And here's what I've changed to remap some of the keys to do what I wanted:

# Override the character equivalents to word equivalents
# - Moving back a character is already accomplished by the arrow keys on
#   keyboard, and Meta-{b,f} are annoying, so remap to Control-{b,f}
# HINT:
# - To move multiple characters, do \M-<num>\C-{b,f} where <num> is number
#   of words
# - To navigate forward to a matching character \C-]<char> where <char> is
#   the character to search
Control-b: backward-word
Control-f: forward-word

# All the deletion commands, go try to remember them
#   kill from cursor to beginning of line
# - Control-k: kill-line
#   kill from cursor to end of line
# - Control-w: unix-word-rubout
#   delete one word backwards, but it does some funky cursor positioning
# - Meta-d: kill-word
#   delete one word forward
# - Meta-DEL: backward-kill-word
#   delete one word backward, basically this is normally what I want
Control-g: "\C-b\ed"  slightly better than backward-kill-word, can kill from middle of word
"\C-x\C-b": unix-filename-rubout  extract filename component from hopefully what is a path

# powerline shell often messes up the line, use this to restore line
"\C-x\C-l": redraw-current-line

# The above are all cut commands, so to paste, undo, revert
# Control-y: yank (this is paste)
# Control-_: undo
# Meta-r: revert-line undo the whole line

# Macros! They are a little bit of a hit-and-miss and there's no visual feedback
# "\C-x(": start-kbd-macro
# "\C-x)": end-kbd-macro
# "\C-xe": call-last-kbd-macro
"\C-xp": print-last-kbd-macro   does not actually work...

# Other miscellaneous commands
# "\C-x\C-x": toggle position
"\C-x\C-d": dump-variables  some means of debugging...