4

Really simple question. I know I can exit bash with "exit", CTRL-D, etc, and yes I know I'm using a Linux (sub)system, but when I'm on windows ALT-F4 is second nature. Naturally, I'm on windows when using WSL. I've managed to get it to exit when I type "`" (backtick) persistently via bashrc with a bind -x '"`":"exit"'.
I can also get it to work per session with ALT-F4 by getting the keymap for ALT-F4 via CTRL-V, ALT-F4, (something like ^[[1;3S) and binding that to exit, but again, only for that session.

but if I use that same bind that exits per-session in my .bashrc and reload, it does not work, spitting out text (generally ;3S) instead. I know it's a trivial problem, I'd appreciate the help anyway.
Thanks

  • You may need to put it in .inputrc instead of .bashrc. – Weijun Zhou Jan 4 '18 at 15:34
0

Consulted a friend, found answer. ";3S" was added on to the end of the keybind, though neither of us are sure why.
Regardless, adding bind -x '"\e[1":"exit"' to .bashrc or .bash_aliases (assuming it exists), will do the trick. it only works from bash, (i.e., if you're in VIM or whatever, it wont exit), but it's not a text replace like standard bind, so it can be used when the line isn't empty.

Obligatory Disclaimer for those in the future who may want to replicate this: Every distro is different, so your key combo may be different. find it, update the command with your key combo, and viola.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.