Deduplicate mistyped shell commands [closed]
Clash 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.
bash shell
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.
add a comment |Â
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.
bash shell
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 calledssh
, sossh ssh
may not be an error. Correcting for this would involve writing abash
command line completion thing that validates the hostname on the command line afterssh
against the network and against your SSH configuration file.
â Kusalananda
Apr 19 at 13:10
1
or a directory namedcd
or a file namedls
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
add a comment |Â
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.
bash shell
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.
bash shell
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 calledssh
, sossh ssh
may not be an error. Correcting for this would involve writing abash
command line completion thing that validates the hostname on the command line afterssh
against the network and against your SSH configuration file.
â Kusalananda
Apr 19 at 13:10
1
or a directory namedcd
or a file namedls
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
add a comment |Â
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 calledssh
, sossh ssh
may not be an error. Correcting for this would involve writing abash
command line completion thing that validates the hostname on the command line afterssh
against the network and against your SSH configuration file.
â Kusalananda
Apr 19 at 13:10
1
or a directory namedcd
or a file namedls
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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
edited Apr 19 at 13:07
Jeff Schaller
31.1k846105
31.1k846105
answered Apr 19 at 11:25
Miguel Leitão
212
212
add a comment |Â
add a comment |Â
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
, sossh ssh
may not be an error. Correcting for this would involve writing abash
command line completion thing that validates the hostname on the command line afterssh
against the network and against your SSH configuration file.â Kusalananda
Apr 19 at 13:10
1
or a directory named
cd
or a file namedls
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