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.

closed as unclear what you're asking by poige, Christopher, Jeff Schaller, Jesse_b, Romeo Ninov Apr 19 '18 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 '18 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 '18 at 13:10
  • 1
    or a directory named cd or a file named ls or ....... – Jeff Schaller Apr 19 '18 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 '18 at 16:16

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.

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