paste

How to copy the macOS Terminal path to the clipboard alvin May 15, 2017 - 9:24am

If you want to copy the current macOS Terminal path to the clipboard, you can do it with this simple command:

$ pwd | pbcopy

pwd prints the path to STDOUT, and pbcopy reads that and copies it to the macOS clipboard. Once the path is on the clipboard you can paste it into your other applications.

Of course you can also create an alias, like this:

alias path="pwd | pbcopy"
How to copy text from the MacOS Terminal to the clipboard alvin April 10, 2017 - 5:48pm

If you ever need to copy text (or a text file) from the MacOS Terminal to the Mac clipboard, I can confirm that the macOS pbcopy command works. It reads from STDIN and copies the text to the clipboard, so commands like these work:

$ echo "foo bar baz" | pbcopy

$ cat /etc/passwd | pbcopy
How to paste and load blocks of code in the Scala REPL alvin June 20, 2015 - 4:10pm

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.2, “How to paste and load blocks of code in the Scala REPL.”

Problem

You want to experiment with some code in the Scala REPL, and typing it in or trying to paste it into the REPL won’t work.

How to enter multiline commands (statements) into the Scala REPL

When you want to test a multiline command/statement in the Scala REPL, you can easily run into a problem where the REPL gets confused, or more accurately, it attempts to evaluate your statement too early.

As a simple example of this, imagine that you want to test the Scala "if" statement syntax. You begin typing your if statement normally, but when you hit [Enter] after your second line, you'll see that everything blows up:

An iPhone select paragraph and copy tip alvin July 29, 2010 - 6:41pm

iPhone copy/paste FAQ - Is there was way to select an entire paragraph on the iPhone (or iPod Touch) when starting a copy and paste process? Copying a paragraph by selecting a word on the iPhone/iPod, and then expanding the selection box is okay, but it's a bit of a slow process.

The vim copy and paste commands

Vim FAQ: What are the vim copy and paste commands?

In vim you can copy and paste content fairly easily, but being an older text editor, these commands aren't obvious. Let's take a look at how to use copy and paste in vim.

The vim cut and paste commands

Vim FAQ: What are the vim cut and paste commands?

In vim you can cut and paste content fairly easily, but being an older text editor, these commands aren't obvious. Let's take a look at how to use cut and paste in vim.

The vim cut command

In short, the vim cut command is dd -- the letter 'd', typed twice. This command deletes the current line, but places it in a buffer, so you can easily paste it somewhere else. You use this command while in the vim command mode.

How to copy files on Mac OS X

Mac "file copy" FAQ: How do I copy files on my Mac?

When people move from Windows to Mac OS X, a common question is "How do I copy files on my Mac?" I hope this short Mac file copying tutorial will help answer that question.

Java: How to get an image off the system clipboard

Java clipboard FAQ: How do I get an image off the clipboard using Java?

I guess timing is everything ... I just received this Java clipboard question as I am working on a Java Swing application that does a lot of graphics and image work, so I have a little source code here I can share.

vim copy and paste commands

vim copy and paste FAQ: How do I copy and paste in vim (the vi or vim editor)?

In this short vi/vim tutorial I thought I'd share the most common vim copy and paste commands I use on a daily basis. I've been using vi (and vim) for almost 20 years now (wow), and these are the most common copy/paste commands I use.