Deduplicate mistyped shell commands [closed]

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











up vote
0
down vote

favorite












Ok, I can bet I'm not the only one that types ssh on the shell command, go look somewhere else what's the hostname, come back and type ssh [hostname], which becomes ssh ssh [hostname].



Then you just fix it, and repeat the same mistake with cd, git, ls, etc. later on. For years. Then decades.



I know one possible solution for that would be to have a hammer on my desk and use it on my hand every time I make this mistake; one day I'd have to learn.



But can anyone suggest a less painful way to solve that on bash?



I know it's possible to do that with trap DEBUG, but.. it seems so risky.



Only thing else I can think of is defining a function for each of these commands that checks the args.







share|improve this question













closed as unclear what you're asking by poige, Christopher, Jeff Schaller, Jesse_b, Romeo Ninov Apr 19 at 18:45


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    what exactly are you asking? And regardless — just have a habit to check what you're press-Entering. Always. Specially when you looked somewhere interim. ;)
    – poige
    Apr 19 at 11:59






  • 1




    There could conceivably exist a host on your network that is called ssh, so ssh ssh may not be an error. Correcting for this would involve writing a bash command line completion thing that validates the hostname on the command line after ssh against the network and against your SSH configuration file.
    – Kusalananda
    Apr 19 at 13:10






  • 1




    or a directory named cd or a file named ls or .......
    – Jeff Schaller
    Apr 19 at 13:24










  • Yeah! all those things could exist; but in the last 15 years they haven't existed for me. I'd be happy treating those exceptions as exceptions if/when they happen.
    – Lem0n
    Apr 19 at 16:16














up vote
0
down vote

favorite












Ok, I can bet I'm not the only one that types ssh on the shell command, go look somewhere else what's the hostname, come back and type ssh [hostname], which becomes ssh ssh [hostname].



Then you just fix it, and repeat the same mistake with cd, git, ls, etc. later on. For years. Then decades.



I know one possible solution for that would be to have a hammer on my desk and use it on my hand every time I make this mistake; one day I'd have to learn.



But can anyone suggest a less painful way to solve that on bash?



I know it's possible to do that with trap DEBUG, but.. it seems so risky.



Only thing else I can think of is defining a function for each of these commands that checks the args.







share|improve this question













closed as unclear what you're asking by poige, Christopher, Jeff Schaller, Jesse_b, Romeo Ninov Apr 19 at 18:45


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    what exactly are you asking? And regardless — just have a habit to check what you're press-Entering. Always. Specially when you looked somewhere interim. ;)
    – poige
    Apr 19 at 11:59






  • 1




    There could conceivably exist a host on your network that is called ssh, so ssh ssh may not be an error. Correcting for this would involve writing a bash command line completion thing that validates the hostname on the command line after ssh against the network and against your SSH configuration file.
    – Kusalananda
    Apr 19 at 13:10






  • 1




    or a directory named cd or a file named ls or .......
    – Jeff Schaller
    Apr 19 at 13:24










  • Yeah! all those things could exist; but in the last 15 years they haven't existed for me. I'd be happy treating those exceptions as exceptions if/when they happen.
    – Lem0n
    Apr 19 at 16:16












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Ok, I can bet I'm not the only one that types ssh on the shell command, go look somewhere else what's the hostname, come back and type ssh [hostname], which becomes ssh ssh [hostname].



Then you just fix it, and repeat the same mistake with cd, git, ls, etc. later on. For years. Then decades.



I know one possible solution for that would be to have a hammer on my desk and use it on my hand every time I make this mistake; one day I'd have to learn.



But can anyone suggest a less painful way to solve that on bash?



I know it's possible to do that with trap DEBUG, but.. it seems so risky.



Only thing else I can think of is defining a function for each of these commands that checks the args.







share|improve this question













Ok, I can bet I'm not the only one that types ssh on the shell command, go look somewhere else what's the hostname, come back and type ssh [hostname], which becomes ssh ssh [hostname].



Then you just fix it, and repeat the same mistake with cd, git, ls, etc. later on. For years. Then decades.



I know one possible solution for that would be to have a hammer on my desk and use it on my hand every time I make this mistake; one day I'd have to learn.



But can anyone suggest a less painful way to solve that on bash?



I know it's possible to do that with trap DEBUG, but.. it seems so risky.



Only thing else I can think of is defining a function for each of these commands that checks the args.









share|improve this question












share|improve this question




share|improve this question








edited Apr 19 at 13:18









mnille

367111




367111









asked Apr 19 at 11:17









Lem0n

1033




1033




closed as unclear what you're asking by poige, Christopher, Jeff Schaller, Jesse_b, Romeo Ninov Apr 19 at 18:45


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by poige, Christopher, Jeff Schaller, Jesse_b, Romeo Ninov Apr 19 at 18:45


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    what exactly are you asking? And regardless — just have a habit to check what you're press-Entering. Always. Specially when you looked somewhere interim. ;)
    – poige
    Apr 19 at 11:59






  • 1




    There could conceivably exist a host on your network that is called ssh, so ssh ssh may not be an error. Correcting for this would involve writing a bash command line completion thing that validates the hostname on the command line after ssh against the network and against your SSH configuration file.
    – Kusalananda
    Apr 19 at 13:10






  • 1




    or a directory named cd or a file named ls or .......
    – Jeff Schaller
    Apr 19 at 13:24










  • Yeah! all those things could exist; but in the last 15 years they haven't existed for me. I'd be happy treating those exceptions as exceptions if/when they happen.
    – Lem0n
    Apr 19 at 16:16












  • 1




    what exactly are you asking? And regardless — just have a habit to check what you're press-Entering. Always. Specially when you looked somewhere interim. ;)
    – poige
    Apr 19 at 11:59






  • 1




    There could conceivably exist a host on your network that is called ssh, so ssh ssh may not be an error. Correcting for this would involve writing a bash command line completion thing that validates the hostname on the command line after ssh against the network and against your SSH configuration file.
    – Kusalananda
    Apr 19 at 13:10






  • 1




    or a directory named cd or a file named ls or .......
    – Jeff Schaller
    Apr 19 at 13:24










  • Yeah! all those things could exist; but in the last 15 years they haven't existed for me. I'd be happy treating those exceptions as exceptions if/when they happen.
    – Lem0n
    Apr 19 at 16:16







1




1




what exactly are you asking? And regardless — just have a habit to check what you're press-Entering. Always. Specially when you looked somewhere interim. ;)
– poige
Apr 19 at 11:59




what exactly are you asking? And regardless — just have a habit to check what you're press-Entering. Always. Specially when you looked somewhere interim. ;)
– poige
Apr 19 at 11:59




1




1




There could conceivably exist a host on your network that is called ssh, so ssh ssh may not be an error. Correcting for this would involve writing a bash command line completion thing that validates the hostname on the command line after ssh against the network and against your SSH configuration file.
– Kusalananda
Apr 19 at 13:10




There could conceivably exist a host on your network that is called ssh, so ssh ssh may not be an error. Correcting for this would involve writing a bash command line completion thing that validates the hostname on the command line after ssh against the network and against your SSH configuration file.
– Kusalananda
Apr 19 at 13:10




1




1




or a directory named cd or a file named ls or .......
– Jeff Schaller
Apr 19 at 13:24




or a directory named cd or a file named ls or .......
– Jeff Schaller
Apr 19 at 13:24












Yeah! all those things could exist; but in the last 15 years they haven't existed for me. I'd be happy treating those exceptions as exceptions if/when they happen.
– Lem0n
Apr 19 at 16:16




Yeah! all those things could exist; but in the last 15 years they haven't existed for me. I'd be happy treating those exceptions as exceptions if/when they happen.
– Lem0n
Apr 19 at 16:16










1 Answer
1






active

oldest

votes

















up vote
2
down vote













Not a solution, but a simple and fast correction method; just enter as your next command:



!*


This will repeat the last issued arguments as a new command.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    Not a solution, but a simple and fast correction method; just enter as your next command:



    !*


    This will repeat the last issued arguments as a new command.






    share|improve this answer



























      up vote
      2
      down vote













      Not a solution, but a simple and fast correction method; just enter as your next command:



      !*


      This will repeat the last issued arguments as a new command.






      share|improve this answer

























        up vote
        2
        down vote










        up vote
        2
        down vote









        Not a solution, but a simple and fast correction method; just enter as your next command:



        !*


        This will repeat the last issued arguments as a new command.






        share|improve this answer















        Not a solution, but a simple and fast correction method; just enter as your next command:



        !*


        This will repeat the last issued arguments as a new command.







        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Apr 19 at 13:07









        Jeff Schaller

        31.1k846105




        31.1k846105











        answered Apr 19 at 11:25









        Miguel Leitão

        212




        212












            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