Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run one command, then bring up a second, but modify it first before pressing enter on it. (Cygwin)

I usually just type it all out like this:

svn up 8.0; ./ 8.0 12345

I also have to do this with different versions and revisions, so after that, I type out all this again for each one:

svn up 8.1; ./ 8.1 12345

The problem is, 12345 always changes, so I have to just up arrow and delete and re type it.

So what I want to do is type this:

m8 12345


m81 12345


m8 54321

For each different one. The results would be:

$ m8 12345
$ svn up 8.0; ./ 8.0 12345

(but not actually run, just typed in for me in the prompt)

$ m81 12345
$ svn up 8.1; ./ 8.1 12345

(but not actually run, just typed in for me in the prompt)

$ m8 54321
$ svn up 8.0; ./ 8.0 54321

(but not actually run, just typed in for me in the prompt)

At that point I could press enter, or change the 12345 around, or do nothing.

share|improve this question
up vote 1 down vote accepted

Create an alias to the first part of the command. When you're done, you can unalias it.

What you would do in your example is:

alias m8='svn up 8.0; ./ 8.0'

Which then lets you do:

m8 12345

When you're done, you can delete the alias:

unalias m8
share|improve this answer

Use bash's history capabilities. Put the following in your .bashrc file:

shopt -s histverify

Now, at the command-line, you can type Controlr, the start typing svn up. It should search back through your history for the first command that begins "svn up". Repeated presses of Controlr will find previous such commands. If at any time you press Enter, the histverify option we set above will cause the currently displayed command to be displayed on the command-line for editing, not executed immediately.

This isn't exactly what you asked for, but may work just as well. It's possible to write a function that might behave similarly ($ m 8.1 54321), but the details are tricky.

share|improve this answer

Write a shell script or function (e.g., called m) that does something like this:

 Validate arguments: $1 and $2 are numeric.
 Compute ver_num from $1; e.g., 8 –> 8.0, 81 –> 8.1
my_command="svn up $ver_num; ./ $ver_num $2"
echo "$my_command"
history -s "$my_command"

You’ll have to run it as m 8 12345 (instead of m8 12345).  The history -s command will put "$my_command" into the history list without executing it, so you should be able to press Cursor Up, optionally edit the command, and press Enter –– or do nothing.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .