Problem Not solved although one answer was accepted: We are working to get Jonah's code to work.
Problem: to change the code of (1) to (2)
I know the thread. I want to be able to run the following code inside Screen
Code (1)
cat ~/.vimrc | pbcopy (1)
Code (2)
cat ~/.vimrc > /tmp/pbcopy.pipe (2)
My attempt to solve the problem: to put the following code to .zshrc
function pbcopy() { "(cat \"$1\")" > /tmp/pbcopy.pipe }
I get
cat masi | pbcopy
pbcopy: command not found: (cat "")
cat: masi: No such file or directory
How can you use pbcopy inside Screen?
This appears to be fixed in Snow Leopard's version of GNU Screen even though it keeps the same version number 4.00.03 (FAU) 23-Oct-06.
Alternatively you can update to Screen version 4.01:
There is a much easier solution to just use osascript as found at http://www.samsarin.com/blog/2008/10/18/copying-gnu-screen-buffer-to-leopard-clipboard/
In the comments, Andrew Wason provides this solution to copy the screen buffer:
Code in your .screenrc
Also using osascript, here's a bash script which emulates the behavior of pbcopy within screen. Improvements to this script are welcome:
Save this code as a bash script somewhere in your path, example: ~/bin/pbcopyScreen.bash
Alright, this is a screwy answer, but it is also a screwy question, so at least they match. You can create a named pipe with
mkfifo
, and then setup an infinite loop that reads files from the named pipe and pipes them topbcopy
(orxsel
,xclip
, etc.).1. In a terminal which is NOT in a screen session (run this only once):
You may want to turn this into a shell script like (this probably should be more robust)
which you can name
pbcopy_server.sh
, make executable (chmod a+x pbcopy_server.sh
) and put somewhere in your path, so you can saynohup pbcopy_server.sh &
when you first start your machine.2. In any other terminal (including those in screen sessions) you can now cat files (or redirect output of programs into /tmp/pbcopy.pipe and the text will appear in the clipboard.
3. To make it look like you are calling the real
pbcopy
you can use something to do the cat'ing to/tmp/pbcopy.pipe
for you.3a. Use a
zsh
function:3b. Or create a Perl script named
pbcopy
and put it in a directory earlier in yourPATH
than/usr/bin
:You may install an older version of Macport's screen which seems to solve this issue, as stated in comments of this article:
link to the last comment explaining how to do
I've tried myself and screen works very fine now with pbcopy ! :-)
Check that step:
Install Macport using its DMG file. Leopard's DMG
Launch a new Terminal and
$ sudo vi /opt/local/etc/macports/sources.conf
finally those 2 lines only remains in sources.conf, no more:
file:///Users/xxxxx/ports
rsync://rsync.macports.org/release/ports/ [default]
$ cd
(do not create a "screen" directory, svn will)$ mkdir -p ports/sysutils/
$ cd ports/sysutils/
$ svn co -r 45745 http://svn.macports.org/repository/macports/trunk/dports/sysutils/screen
Once check out:
$ cd $HOME/ports
$ portindex
Creating software index in /Users/keugaerg/ports Adding port sysutils/screen
$ sudo port install screen
(may take a while as downloading screen and buidling it)Then it's done, just have to launch /opt/local/bin/screen .