Sunday, July 01, 2018

No One Tells You What to Do.... Until Now..

Problem.. your shell bindkeys aren't working and your sys admin would rather be looking at the secretary..

Root cause - using csh - which the dinosaurs *also* deprecated in favour of bash..

So, what's a man to do?

Easy - use the "bindkey" command (csh and tcsh only)

Example, you want ALT-F to do something... instead, it prints a weird character.

So, do :

$ bindkey <now-press-ALT-F-to-get-the-weird-character> forward-word

And you're done..

Same for things like Delete key, etc..

Not helpful enough :

https://www.linuxquestions.org/questions/linux-general-1/insert-and-delete-key-returns-~-in-a-terminal-876401/

https://unix.stackexchange.com/questions/81256/tilde-when-clicking-del-key

Okay, what I've told you so far, gets you to a point - you'll find that, in an xterm session, you can do this and it'll work, but, when you try putting that in a .cshrc, you'll be in for a surprise..

bad key spec

territory :( And stackoverflow ain't much help. That's why you come here..

And the answer? Look up that funny character in the ASCII table - for example, if it's the small a with a  hat on top, take that code, get the octal representation (just go to a new tab and type 226 to octal and let google do the work :)

Then, in your .cshrc

bindkey "\342" forward-word

And you're through.  You're welcome!

No comments: