diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2015, Peter Harpending
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
new file mode 100644
--- /dev/null
+++ b/README.md
@@ -0,0 +1,35 @@
+pipeclip
+========
+
+This program pops open your `$EDITOR` or `$VISUAL`, takes whatever you
+inputted into the file, and pipes it to the X clipboard.
+
+As such, this program only works on Linux and BSD.
+
+I've tested it on Arch Linux and FreeBSD.
+
+Installation
+------------
+
+pipeclip is written in Haskell, so please install Haskell first:
+<https://github.com/bitemyapp/learnhaskell/blob/master/install.md>.
+
+You also need to have `xclip` or `xsel` installed.
+
+Then,
+
+    cabal install pipeclip
+
+Usage
+-----
+
+    pipeclip v.0.1.0.0
+    Copyright (c) 2015, Peter Harpending.
+    Licensed under the FreeBSD license. See --license for info.
+    
+    OPTIONS
+        -h,--help             Show this page
+        --license             Print out the license.
+        --stdout              Print output to stdout instead of piping to the clipboard.
+        -t,--template EXT     Name the temporary file the editor edits tmp.EXT so that 
+                              it has highlighting and stuff.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/pipeclip.cabal b/pipeclip.cabal
new file mode 100644
--- /dev/null
+++ b/pipeclip.cabal
@@ -0,0 +1,51 @@
+name:                pipeclip
+version:             0.1.0.0
+synopsis:            Open your editor, pipe the output to the system clipboard
+description:         
+  This opens up your @$EDITOR@ or @$VISUAL@ using the 
+  <https://hackage.haskell.org/package/editor-open @editor-open@ library.> It
+  then takes the edited text and sends it to the X11 clipboard.
+  .
+  As such, this will only work if you have X11. Translated, this is limited to
+  Linux and BSD.
+homepage:            https://github.com/pharpend/pipeclip
+license:             BSD2
+license-file:        LICENSE
+author:              Peter Harpending
+maintainer:          peter@harpending.org
+copyright:           Copyright (c) 2015, Peter Harpending.
+category:            System, Text
+build-type:          Simple
+cabal-version:       >=1.10
+bug-reports:         https://github.com/pharpend/pipeclip/issues
+extra-source-files:  
+  LICENSE
+  README.md
+data-files:  
+  README.md
+  LICENSE
+
+executable pipeclip
+  main-is:             pipeclip.hs
+  other-modules:       
+    Paths_pipeclip
+  other-extensions:    
+    CPP
+    MultiWayIf
+    OverloadedStrings
+  default-language:    Haskell2010
+  build-depends:
+      base ==4.*
+    , bytestring
+    , editor-open
+    , Hclip
+    , safe
+
+source-repository head
+  type: git
+  location: git://github.com/pharpend/pipeclip.git
+
+source-repository this
+  type: git
+  location: git://github.com/pharpend/pipeclip.git
+  tag: master
diff --git a/pipeclip.hs b/pipeclip.hs
new file mode 100644
--- /dev/null
+++ b/pipeclip.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MultiWayIf #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+module Main where
+
+import qualified Data.ByteString as B
+import Data.ByteString.Char8 (pack, unpack)
+import Data.List
+import Paths_pipeclip
+import Safe
+import System.Hclip
+import System.Environment
+import System.IO
+import Text.Editor
+
+#if !(MIN_VERSION_base (4,8,0))
+import Data.Monoid
+#endif
+
+data Args =
+  Args {help :: Bool
+       ,license :: Bool
+       ,toStdout :: Bool
+       ,template :: String}
+
+main :: IO ()
+main =
+  do stdargs <- getArgs
+     runArgs (Args (or ["--help" `elem` stdargs,"-h" `elem` stdargs])
+                   ("--license" `elem` stdargs)
+                   ("--stdout" `elem` stdargs)
+                   (case findIndex (\x ->
+                                      (x == "--template") ||
+                                      (x == "-t"))
+                                   stdargs of
+                      Just i ->
+                        at stdargs (i + 1)
+                      Nothing -> "txt"))
+
+runArgs :: Args -> IO ()
+runArgs (Args help_ license_ sto templ) =
+  if |  license_ ->
+       do licensePath <-
+            getDataFileName "LICENSE"
+          licenseBytes <- B.readFile licensePath
+          B.hPut stdout licenseBytes
+     |  not help_ -> runClip sto templ
+     |  otherwise ->
+       B.hPut stdout
+              (pack (mappend (unlines ["pipeclip v.0.1.0.0"
+                                      ,"Copyright (c) 2015, Peter Harpending."
+                                      ,"Licensed under the FreeBSD license. See --license for info."
+                                      ,mempty
+                                      ,"OPTIONS"])
+                             (unlines (fmap (mappend (replicate 4 ' '))
+                                            ["-h,--help             Show this page"
+                                            ,"--license             Print out the license."
+                                            ,"--stdout              Print output to stdout instead of piping to the clipboard."
+                                            ,"-t,--template EXT     Name the temporary file the editor edits tmp.EXT so that "
+                                            ,"                      it has highlighting and stuff."]))))
+
+runClip :: Bool -> String -> IO ()
+runClip sto templ =
+  do bs <-
+       runUserEditorDWIM (mkTemplate templ)
+                         "Edit this here text."
+     if sto
+        then B.hPut stdout bs
+        else setClipboard (unpack bs)
