Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Given a very long single command at the command line in Windows, I'd like to simply copy that command into clipboard.

I am just looking for the ubiquitous Shift-End , Ctrl-C type functionality almost all editors have.

I DON'T want to use Mark (yes, even in QuickEdit mode), which requires me to select the block, paste it somewhere, and remove the carriage returns manually.
Granted, this isn't that hard, but I have a (reasonable) scenario where I am doing this quite a bit and it becomes a hassle.

Cygwin is also not an option, since it does a few things differently, which won't work for my scenario.

Edit, Chosen Answer:
I went with a combination of romandas' and crchad's answers, I am now using the "Console" program for multiple tabs and romandas' suggestion of the "clip" program totally improved the flow:

  • Type out my lengthy command and run it
  • Hit up for previous command and add |clip to the end
  • Hit Home, add echo to the beginning

MUCH Faster than the block editing I was doing before. Thanks!

share|improve this question
    
Do you want something built-in or will third-party command-prompt utilities work for you? –  romandas Aug 5 '09 at 20:00
    
either way.. Your clip suggestion seems sound. Doesn't appear it's on XP, going to find and try now, thanks –  Kevin Radcliffe Aug 5 '09 at 20:07
1  
According to technet.microsoft.com/en-us/library/dd996683%28WS.10%29.aspx, clip is only on Windows 2003. Maybe you can copy it over? –  romandas Aug 5 '09 at 20:18
    
Thanks again romandas, My Win2k3 copy of clip.exe did work just fine on Windows XP –  Kevin Radcliffe Aug 5 '09 at 20:32
    
Sweet. Glad to be of assistance. –  romandas Aug 5 '09 at 20:47
add comment

4 Answers

up vote 14 down vote accepted

Not sure there is an answer to this when using a mouse. If you wanted a command-line way to do it, you can just echo the command and pipe that output to clip:

echo stuff you wanted copied to the clipboard | clip

FYI, clip is available on Windows 2003. I believe it is a built-in.

share|improve this answer
    
+1 for typing faster than me :) –  Kevin Kuphal Aug 5 '09 at 19:54
    
Excellent - this will save me a lot of anguish :) –  Izzy Aug 5 '09 at 20:25
    
+1 - Oh HELL yes! Why didn't I know this command existed? –  Evan Anderson Aug 6 '09 at 22:18
    
@Evan - Given your rep, I'll take that comment as better than any badge. Well.. okay.. maybe better than any non-Gold badge. ;) –  romandas Aug 6 '09 at 22:38
add comment

I can recommend Console. It copies multiple lines more sanely.

FYI: I find the default mouse button options are different from cmd, so you may wish to change them.

share|improve this answer
    
Good find. Also, the multiple tabs capability is great (why isn't this in the regular windows command prompt be now?) Thanks. –  Kevin Radcliffe Aug 5 '09 at 20:47
1  
You're right, the tabs are really handy. And you can set tabs to use different shells e.g. to use powershell instead of cmd.exe –  Chris Aug 6 '09 at 1:18
    
Didn't notice that before, that makes it even more awesome. Thanks again. –  Kevin Radcliffe Aug 6 '09 at 16:40
add comment

Take Command is an alternative command line that does support keyboard copy and paste. Your going to have issues using ctl-c as copy though, as that is usually the command to stop a process.

share|improve this answer
    
This is pay software, and the answers above got me what I needed, but Take Command does look very capable! I'll have to check out their evaluation copy, thanks for the tip on this. –  Kevin Radcliffe Aug 5 '09 at 20:45
    
re: control-C - Ctrl-Ins & Shift-Ins also work for copy and paste. can't remember if it works from CMD.EXE but it certainly works in every windows dialog box input field i've ever tried it on. –  cas Aug 5 '09 at 21:02
add comment

Use QuickEdit mode and Hit "Enter" to copy.

Edit: Whoops I missed that you don't want to use QuickEdit and select with the mouse, etc... One way to do this is use the "set" command to give each of your command strings a variable. Example:

set cmd1=somecommand /switch /anotherswitch

To use it just type %cmd1%

share|improve this answer
    
I didn't mention above, but the command I must use varies quite a bit. Your answer is a good reminder though to try to refactor to variables where possible, thanks. –  Kevin Radcliffe Aug 5 '09 at 20:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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