Pastebin.com is a website where you can store and share text or code for a certain period of time. Pastebin support syntax highlight for a variety of programming language. However, it is sometimes tedious to open the website and copy-paste your code. PastebinCL is a small command line utility help you to paste text to Pastebin directly from terminal.
Before compiling PastebinCL, you have to sign up a Pastebin account to get a unique developer api key. Then, download the tarball of PastebinCL from Pastebin website. Extract the tarball and compile with make
. You need to enter your developer api key here. Then, you may or may not meet errors during the process. If you meet some problems, you need to modify src/Makefile to make PastebinCL. See later content for some tips.
$ tar -xzf pastebincl-1.0.tar.gz
$ cd pastebincl-1.0
$ make
cd src/ && make
-e
Enter your Pastebin Developper API Key (see http://pastebin.com/api), or leave blank to use the default one (may not work):
# enter your Pastebin developer api key here
{{< / highlight >}}
Then, move `pastebincl` to any execution directory like */usr/local/bin* for later use.
To paste text with your Pastebin account, type `pastebincl --usergen` and input your account name and password:
```console
$ pastebincl --usergen
{{< / highlight >}}
There are two ways to use PastebinCL. You can type `pastebincl` with or without parameters and begin to type your text for paste. Next, press `Ctrl-d` to paste your text.
```console
$pastebincl -n hello -s python
print "Hello World!"
# press Ctrl-d...
Submitting paste...
Paste submitted successfully!
URL: http://pastebin.com/VG858r4H
{{< / highlight >}}
Another way to paste text is to combine `cat` and `pastebincl`:
```console
$ cat example.rb | pastebincl -n "a example file" -s ruby
{{< / highlight >}}
To see more usage, type `pastebincl --help` in the terminal.
### Troubleshooting on OS X
You may meet the following error:
```console
clang: error: -lcurl: 'linker' input unused
make[1]: *** [CurlPost.o] Error 1
make: *** [pastebincl] Error 2
{{< / highlight >}}
To solve the problem, modify *src/Makefile* and delete **$(CXXLIBS)** in the following section:
```make
# before modification...
ConfigRead.o: ConfigRead.cpp
$(CXX) $(CXXLIBS) -c $< $(CXXFLAGS) -o $@ -DENCODING_KEY=\"${ENC_KEY}\"
%.o: %.cpp
$(CXX) $(CXXLIBS) -c $< $(CXXFLAGS) -o $@
# after modification...
ConfigRead.o: ConfigRead.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@ -DENCODING_KEY=\"${ENC_KEY}\"
%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
{{< / highlight >}}
Then, you may meet the following error:
```console
ConfigRead.cpp:50:12: error: comparison of constant with
expression of type 'unsigned int' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
if(findpos!=string::npos)
~~~~~~~^ ~~~~~~~~~~~~
{{< / highlight >}}
In this case, modify *src/Makefile* and delete **-Werror** in **CXXFLAGS**:
```make
# before modification...
CXXFLAGS=-Wall -Werror -O2
# after modification...
CXXFLAGS=-Wall -O2
{{< / highlight >}}
### Troubleshooting on Ubuntu
If you are using Ubuntu, you have to install *libcurl4-dev*, which is a virtual package. You may choose one from *libcurl4-openssl-dev*, *libcurl4-nss-dev* and *libcurl4-gnutls-dev*.
```console
$ sudo apt-get install libcurl4-openssl-dev
{{< / highlight >}}
Because Ubuntu replace `bash` with `dash` as default link of `/bin/sh`. You have to modify *src/Makefile* and add **SHELL** variable in the top section of the Makefile:
```make
SHELL=/bin/bash
{{< / highlight >}}
Then, you may meet the following error:
```console
# some message omitted...
CurlPost.o: In function `CurlPost::clean()':
CurlPost.cpp:(.text+0x251): no reference to「curl_global_cleanup」
collect2: error: ld returned 1 exit status
make[1]: *** [pastebincl] Error 1
make[1]: Leaving directory `/home/cwchen/src/pastebincl-1.0/src'
make: *** [pastebincl] Error 2
{{< / highlight >}}
In this case, you need to modify the location of **$(CXXLIBS)** in the following section:
```make
# before modification...
$(TARGET): $(OBJS)
$(CXX) $(CXXLIBS) $^ $(CXXFLAGS) -o $@
# after modification...
$(TARGET): $(OBJS)
$(CXX) $^ $(CXXFLAGS) -o $@ $(CXXLIBS)
{{< / highlight >}}