Way to bind ALT-F4 to exit in Bash (Bash on Ubuntu on Windows)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












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







share|improve this question




















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














up vote
3
down vote

favorite












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







share|improve this question




















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












up vote
3
down vote

favorite









up vote
3
down vote

favorite











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







share|improve this question












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









share|improve this question











share|improve this question




share|improve this question










asked Jan 4 at 13:27









Andrew Baumher

162




162











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
















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















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




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










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










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.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f414767%2fway-to-bind-alt-f4-to-exit-in-bash-bash-on-ubuntu-on-windows%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    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.






    share|improve this answer
























      up vote
      0
      down vote



      accepted










      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.






      share|improve this answer






















        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 6 at 14:41









        Andrew Baumher

        162




        162






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f414767%2fway-to-bind-alt-f4-to-exit-in-bash-bash-on-ubuntu-on-windows%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay