$ clip.exe -?
CLIPDescription:Redirects output of command line tools to the Windows clipboard.This text output can then be pasted into other programs.Parameter List:/? Displays this help message.Examples:DIR | CLIP Places a copy of the current directorylisting into the Windows clipboard.CLIP < README.TXT Places a copy of the text from readme.txton to the Windows clipboard.
#!/bin/bash# WF 2013-10-04## Multi-platform clipboard read access## Supports# Mac OS X# Git shell / Cygwin (Windows)# Linux (e.g., Ubuntu)
## Display an error#error() {echo "error: $1" 1>&2exit 1}
## getClipboard#function getClipboard() {os=`uname`case $os in# Git Bash (Windows)MINGW32_NT-6.1)cat /dev/clipboard;;# Mac OS XDarwin*)pbpaste;;# LinuxLinux*)# Works only for the X clipboard - a check that X is running might be duexclip -o;;*)error "unsupported os $os";;esac}
tmp=/tmp/clipboard$$getClipboard >$tmpcat $tmp# Comment out for debuggingrm $tmp
#!/usr/bin/python
import sys
# Clipboard storageclipboard_file = '/tmp/clipboard.tmp'
if(sys.stdin.isatty()): # Should write clipboard contents out to stdoutwith open(clipboard_file, 'r') as c:sys.stdout.write(c.read())elif(sys.stdout.isatty()): # Should save stdin to clipboardwith open(clipboard_file, 'w') as c:c.write(sys.stdin.read())
# append to clipboard:cat 'the file with content' | xsel -ab
# or type in the happy face :) and ...echo 'the happy face :) and content' | xsel -ib
# show clipboardxsel -ob
# Get more info:man xsel
$ foo -vError: not a real TTYdetails:blah blah @ 0x0000000040abeaf4blah blah @ 0x0000000040abeaf8blah blah @ 0x0000000040abeafcblah blah @ 0x0000000040abeb00...$ foo -v | DISPLAY=:1 xsel -b # copies it into clipboard of display :1
然后我可以像往常一样将Ctrl+V转换为形式。
现在假设支持站点上有人给我一个命令来运行以解决问题。它很复杂而且很长。
$ DISPLAY=:1 xsel -bosudo foo --update --clear-cache --source-list="http://foo-software.com/repository/foo/debian/ubuntu/xenial/164914519191464/sources.txt"$ $(DISPLAY=:1 xsel -bo)Password for braden:UPDATING %%%%%%%%%%%%%%%%%%%%%%% 100.00%Clearing cache...Fetching sources...Reticulating splines...Watering trees...Climbing mountains...Looking advanced...Done.$ fooThank you for your order. A pizza should arrive at your house in the next 20 minutes. Your total is $6.99
:%y+ ; copy/yank (y) everything (%) into the CLIPBOARD selection (+)"+p ; select (") the CLIPBOARD selection (+) and paste/put itggVG"+y ; Alternative version of the first example