copy/paste in terminal?

Discussion in 'Jailbreaks and iOS Hacks' started by TSX, Jan 28, 2010.

  1. TSX macrumors 68030

    TSX

    Joined:
    Oct 1, 2008
    Location:
    Texas
  2. tctony macrumors 6502a

    tctony

    Joined:
    Jun 15, 2009
    #2
    Somebody needs to write a tutorial for MobileTerminal. I didn't realize that if you held down on the screen for a second or so/moved your thumb up that options came up.
     
  3. The General macrumors 601

    Joined:
    Jul 7, 2006
    #3
    where is the cmd key on the iphone? and which mouse are you using with your iphone?
     
  4. foob macrumors 6502

    foob

    Joined:
    Feb 17, 2009
    #4
    I haven't worked on copying but I use these two scripts to paste. The first one is not as good as it just grabs the top line from the SBSettings fast notes, so you have to paste into fast notes first, then access it from the terminal. It can be useful though.

    Code:
    #! /bin/sh
    head -1 /var/mobile/Library/SBSettings/note.txt
    This next one is better. It requires awk and PasteBoardStacker (dont remember the repo right now, but can find it tomorrow if needed). I would have used the system's PasteBoard, but it's half gibberish and I haven't tried to decode it yet.

    PasteBoardStacker keeps a list of the things you have copied so you can click on them to paste. It can remember 20-100 items but you can change it's plist to less. I have it set for 3, which is plenty for me. This script will paste the last thing copied by grabbing it from PasteBoardStacker so everything is transparent. You copy it from another app then run this script and it automatically pastes to in Terminal.

    I call this one "clip" and it can be used it two ways, which you may already recognize. The first is just typing clip and piping it to other commands, the second is using a sub-shell. If you want to download a file, for example, copy the link and use "wget $(clip)" in terminal. $(clip) will run first so the result is "wget www.link.com"

    Code:
    #! /bin/sh
    awk 'BEGIN{ RS="</string>"}{gsub(/.*<string>/,"");print;exit}' /var/mobile/Library/Preferences/com.hitoriblog.pasteboardstacker.plist
    I may try to work on some sort of copy. It wouldn't be a highlight/copy obviously, but it shouldn't be too hard to pipe to a "copy" script that gets the text into PasteBoardStacker's list.
     
  5. TSX thread starter macrumors 68030

    TSX

    Joined:
    Oct 1, 2008
    Location:
    Texas
    #5
    I really just need to paste in mobile terminal.

    Exactly how do i use this?
     
  6. thelatinist macrumors 603

    thelatinist

    Joined:
    Aug 15, 2009
    Location:
    Connecticut, USA
    #6
  7. foob macrumors 6502

    foob

    Joined:
    Feb 17, 2009
    #7
    Copy and paste it into a text file. Name it whatever you want, like "paste", no extension is needed. Put it in /bin then type this in the terminal chmod 755 /bin/paste. Its ready to use, just type "paste" in terminal.

    If you use windows, I would suggest doing this all on the phone and not the computer. If you put it in a file and transfer it to the phone, windows can mess up the line breaks.


    This next one should work for "copy." To use, pipe output to it like: echo "hello world" | copy and "hello world" will then show up in the PasteBoardStacker clipboard.

    I will work on improving this one because the text won't be in the Apple PasteBoard, you have to select the text from PasteBoardStacker by tapping the status bar and tapping the text. It's still a good way to get text from terminal to another app though. Special characters also to be escaped. echo "this is a test!" | ./copy won't work but echo "this is a test\!" | ./copy will.

    Code:
    #! /bin/sh
    in=$(cat -)
    text=$(echo '<string>'"$in"'</string>')
    file=/var/mobile/Library/Preferences/com.hitoriblog.pasteboardstacker.plist
    sed -i "7i\\
    $text" $file
     
  8. jamesapp macrumors 6502a

    Joined:
    Mar 7, 2008
    #8
    Does anyone know how to copy and paste in mobileterminal? I looked for pasteboardstacker but couldn't add the moyashi source in cydia.

    Is there an alternative clipboard manager for the iPhone? I have a 3gs on 3.1.3 fw. Also any info on how to cut and paste in mobileterminal would be helpful.
     

Share This Page