What is a keyboard shortcut for closing a Windows PowerShell window?












0















I have opened an empty Windows PowerShell window, and have not yet entered any commands into the window. The default, unchanged directory is my user account folder. I want to close the window with a keyboard shortcut.





Does NOT work:




  • Ctrl-w (Adds the text ^W into the editor)


  • Ctrl-d (Adds the text ^D into the editor)


  • Alt-F4 (Does nothing)


  • exit followed by {Enter} (Works, but is a cumbersome sequence)





Is there any native solution to this problem without using an AutoHotkey script? I am using Windows 10.










share|improve this question




















  • 1





    I can't test now, but Alt+space generally opens pop-up menu and then "c" closes the application.

    – Máté Juhász
    Dec 28 '18 at 2:55


















0















I have opened an empty Windows PowerShell window, and have not yet entered any commands into the window. The default, unchanged directory is my user account folder. I want to close the window with a keyboard shortcut.





Does NOT work:




  • Ctrl-w (Adds the text ^W into the editor)


  • Ctrl-d (Adds the text ^D into the editor)


  • Alt-F4 (Does nothing)


  • exit followed by {Enter} (Works, but is a cumbersome sequence)





Is there any native solution to this problem without using an AutoHotkey script? I am using Windows 10.










share|improve this question




















  • 1





    I can't test now, but Alt+space generally opens pop-up menu and then "c" closes the application.

    – Máté Juhász
    Dec 28 '18 at 2:55
















0












0








0








I have opened an empty Windows PowerShell window, and have not yet entered any commands into the window. The default, unchanged directory is my user account folder. I want to close the window with a keyboard shortcut.





Does NOT work:




  • Ctrl-w (Adds the text ^W into the editor)


  • Ctrl-d (Adds the text ^D into the editor)


  • Alt-F4 (Does nothing)


  • exit followed by {Enter} (Works, but is a cumbersome sequence)





Is there any native solution to this problem without using an AutoHotkey script? I am using Windows 10.










share|improve this question
















I have opened an empty Windows PowerShell window, and have not yet entered any commands into the window. The default, unchanged directory is my user account folder. I want to close the window with a keyboard shortcut.





Does NOT work:




  • Ctrl-w (Adds the text ^W into the editor)


  • Ctrl-d (Adds the text ^D into the editor)


  • Alt-F4 (Does nothing)


  • exit followed by {Enter} (Works, but is a cumbersome sequence)





Is there any native solution to this problem without using an AutoHotkey script? I am using Windows 10.







windows-10 keyboard-shortcuts powershell exit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 3 at 5:10







Frank Fanelli

















asked Dec 28 '18 at 2:13









Frank FanelliFrank Fanelli

123




123








  • 1





    I can't test now, but Alt+space generally opens pop-up menu and then "c" closes the application.

    – Máté Juhász
    Dec 28 '18 at 2:55
















  • 1





    I can't test now, but Alt+space generally opens pop-up menu and then "c" closes the application.

    – Máté Juhász
    Dec 28 '18 at 2:55










1




1





I can't test now, but Alt+space generally opens pop-up menu and then "c" closes the application.

– Máté Juhász
Dec 28 '18 at 2:55







I can't test now, but Alt+space generally opens pop-up menu and then "c" closes the application.

– Máté Juhász
Dec 28 '18 at 2:55












2 Answers
2






active

oldest

votes


















1














While Alt+Space, then c works as pointed out above without any changes, it still requires two key strokes. You can define your own exit shortcut in PowerShell 5.0 and up by addding a Set-PSReadLineKeyHandler command to your Powershell profile. While this does require editing your PS Profile, once set up it works for all future sessions of PowerShell. As an example,





  1. Open a PowerShell terminal window and type the following to edit your PowerShell Profile file:



    notepad $Profile




This will open your Powershell profile. If you'd like this to work for all users, edit the AllUsers profile which is located at $PROFILE.AllUsersCurrentHost. For more information on the PS profile see this Microsoft reference page.





  1. Add the following to the first line of the profile (ViExit is only available in PS 5.1):



    Set-PSReadlineKeyHandler -Chord Alt+F4 -Function ViExit




This defines the Alt-F4 as the exit key command. If you'd like to use Ctrl-D instead use this line:



Set-PSReadlineKeyHandler -Chord Ctrl+D -Function DeleteCharOrExit



Now close the PowerShell terminal and reopen. The shortcut keys defined above (Alt-F4 or Ctrl-D as applicable) should now work.






share|improve this answer
























  • This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

    – Frank Fanelli
    Dec 29 '18 at 2:53





















0














Try Alt+Space c meaning Alt and space together for the popup menu, then press c for Close






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388293%2fwhat-is-a-keyboard-shortcut-for-closing-a-windows-powershell-window%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    While Alt+Space, then c works as pointed out above without any changes, it still requires two key strokes. You can define your own exit shortcut in PowerShell 5.0 and up by addding a Set-PSReadLineKeyHandler command to your Powershell profile. While this does require editing your PS Profile, once set up it works for all future sessions of PowerShell. As an example,





    1. Open a PowerShell terminal window and type the following to edit your PowerShell Profile file:



      notepad $Profile




    This will open your Powershell profile. If you'd like this to work for all users, edit the AllUsers profile which is located at $PROFILE.AllUsersCurrentHost. For more information on the PS profile see this Microsoft reference page.





    1. Add the following to the first line of the profile (ViExit is only available in PS 5.1):



      Set-PSReadlineKeyHandler -Chord Alt+F4 -Function ViExit




    This defines the Alt-F4 as the exit key command. If you'd like to use Ctrl-D instead use this line:



    Set-PSReadlineKeyHandler -Chord Ctrl+D -Function DeleteCharOrExit



    Now close the PowerShell terminal and reopen. The shortcut keys defined above (Alt-F4 or Ctrl-D as applicable) should now work.






    share|improve this answer
























    • This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

      – Frank Fanelli
      Dec 29 '18 at 2:53


















    1














    While Alt+Space, then c works as pointed out above without any changes, it still requires two key strokes. You can define your own exit shortcut in PowerShell 5.0 and up by addding a Set-PSReadLineKeyHandler command to your Powershell profile. While this does require editing your PS Profile, once set up it works for all future sessions of PowerShell. As an example,





    1. Open a PowerShell terminal window and type the following to edit your PowerShell Profile file:



      notepad $Profile




    This will open your Powershell profile. If you'd like this to work for all users, edit the AllUsers profile which is located at $PROFILE.AllUsersCurrentHost. For more information on the PS profile see this Microsoft reference page.





    1. Add the following to the first line of the profile (ViExit is only available in PS 5.1):



      Set-PSReadlineKeyHandler -Chord Alt+F4 -Function ViExit




    This defines the Alt-F4 as the exit key command. If you'd like to use Ctrl-D instead use this line:



    Set-PSReadlineKeyHandler -Chord Ctrl+D -Function DeleteCharOrExit



    Now close the PowerShell terminal and reopen. The shortcut keys defined above (Alt-F4 or Ctrl-D as applicable) should now work.






    share|improve this answer
























    • This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

      – Frank Fanelli
      Dec 29 '18 at 2:53
















    1












    1








    1







    While Alt+Space, then c works as pointed out above without any changes, it still requires two key strokes. You can define your own exit shortcut in PowerShell 5.0 and up by addding a Set-PSReadLineKeyHandler command to your Powershell profile. While this does require editing your PS Profile, once set up it works for all future sessions of PowerShell. As an example,





    1. Open a PowerShell terminal window and type the following to edit your PowerShell Profile file:



      notepad $Profile




    This will open your Powershell profile. If you'd like this to work for all users, edit the AllUsers profile which is located at $PROFILE.AllUsersCurrentHost. For more information on the PS profile see this Microsoft reference page.





    1. Add the following to the first line of the profile (ViExit is only available in PS 5.1):



      Set-PSReadlineKeyHandler -Chord Alt+F4 -Function ViExit




    This defines the Alt-F4 as the exit key command. If you'd like to use Ctrl-D instead use this line:



    Set-PSReadlineKeyHandler -Chord Ctrl+D -Function DeleteCharOrExit



    Now close the PowerShell terminal and reopen. The shortcut keys defined above (Alt-F4 or Ctrl-D as applicable) should now work.






    share|improve this answer













    While Alt+Space, then c works as pointed out above without any changes, it still requires two key strokes. You can define your own exit shortcut in PowerShell 5.0 and up by addding a Set-PSReadLineKeyHandler command to your Powershell profile. While this does require editing your PS Profile, once set up it works for all future sessions of PowerShell. As an example,





    1. Open a PowerShell terminal window and type the following to edit your PowerShell Profile file:



      notepad $Profile




    This will open your Powershell profile. If you'd like this to work for all users, edit the AllUsers profile which is located at $PROFILE.AllUsersCurrentHost. For more information on the PS profile see this Microsoft reference page.





    1. Add the following to the first line of the profile (ViExit is only available in PS 5.1):



      Set-PSReadlineKeyHandler -Chord Alt+F4 -Function ViExit




    This defines the Alt-F4 as the exit key command. If you'd like to use Ctrl-D instead use this line:



    Set-PSReadlineKeyHandler -Chord Ctrl+D -Function DeleteCharOrExit



    Now close the PowerShell terminal and reopen. The shortcut keys defined above (Alt-F4 or Ctrl-D as applicable) should now work.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 28 '18 at 7:39









    CoderBlueCoderBlue

    512




    512













    • This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

      – Frank Fanelli
      Dec 29 '18 at 2:53





















    • This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

      – Frank Fanelli
      Dec 29 '18 at 2:53



















    This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

    – Frank Fanelli
    Dec 29 '18 at 2:53







    This pointed me in the correct direction...but two things had to be done first: (1.) I had to set the execution policy of PowerShell using the following command (as admin): Set-ExecutionPolicy RemoteSigned (2.) I had to create a Profile before I could edit one, with the following command: New-Item -path $profile -type file –force

    – Frank Fanelli
    Dec 29 '18 at 2:53















    0














    Try Alt+Space c meaning Alt and space together for the popup menu, then press c for Close






    share|improve this answer






























      0














      Try Alt+Space c meaning Alt and space together for the popup menu, then press c for Close






      share|improve this answer




























        0












        0








        0







        Try Alt+Space c meaning Alt and space together for the popup menu, then press c for Close






        share|improve this answer















        Try Alt+Space c meaning Alt and space together for the popup menu, then press c for Close







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 28 '18 at 6:44

























        answered Dec 28 '18 at 6:31









        David HatchDavid Hatch

        215




        215






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388293%2fwhat-is-a-keyboard-shortcut-for-closing-a-windows-powershell-window%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to make a Squid Proxy server?

            Is this a new Fibonacci Identity?

            19世紀