1

I'm inside a terminal.app with about 20 lines of commands and it's output

$ previous command
previous command output
$  git branch
    develop
    master
    * you/236-add-more-test
$ previous command
$ previous command output
$ git checkout <cursor is here now> 

I started typing a command ("git checkout "), Without resorting to the mouse, how can I copy an arbitrary piece of text (in this case I want to copy "you/236-add-more-test" and paste it at the cursor/prompt.

Why not use mouse you ask? the mouse "breaks my flow"

Update: Thanks for the comment klanomath. The fact that I want might want to copy some of its output is not known at the time of issuing the command. So your answer was not what I was looking for. I also don't want to reissue the command just for the purpose of extracting it's output.

Update2: What I tried
Searched google for terminal.app plugins
read https://www.iterm2.com/documentation-utilities.html
read https://github.com/w0lfschild/SIMBLPlugins

  • git checkout $(git branch | sed magic) ;-) [man sed](file:///usr/share/man/man1/sed.1) – klanomath Dec 8 '17 at 1:57
  • 1
    Then use screen to run your commands! It allows a cursor mode and copy and paste. Steep learning curve though! – klanomath Dec 8 '17 at 3:25
  • I never know when this "copy to clipboard" need arises. And running screen "all the time" is not an acceptable answer, because screen just doesn't cut it in some situations. for one, with screen, you lose the Apple Mac Terminal.app's cool super fast super smooth scrolling with trackpad. – american-ninja-warrior Dec 8 '17 at 3:45
  • 1
    I still use the mouse to select text, but then use the keyboard (CMD-C and CMD-V). That's the best I have found, and I really like it (on other systems, there's only CTRL-C and CTRL-V, but these keys don't work as expected in the terminal. – Axel Dec 8 '17 at 5:36
  • You might have better luck with this using iTerm2... – Harv Dec 8 '17 at 16:47

You must log in to answer this question.

Browse other questions tagged .