-
-
Save judofyr/c75681ce99f8c2515ee6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Mac:</p> | |
<p><pre class="sunburst"><br /> | |
<span class="Comment"><span class="Comment">#</span> stick in .irbrc</span><br /> | |
<span class="Keyword">def</span> <span class="Entity">copy</span>(<span class="Variable">str</span>)<br /> | |
<span class="Variable">IO</span>.<span class="Entity">popen</span>(<span class="String"><span class="String">‘</span>pbcopy<span class="String">’</span></span>, <span class="String"><span class="String">‘</span>w<span class="String">’</span></span>) { |<span class="Variable">f</span>| f <span class="Keyword"><<</span> str.<span class="Entity">to_s</span> }<br /> | |
<span class="Keyword">end</span><br /> | |
<br /> | |
<span class="Keyword">def</span> <span class="Entity">paste</span><br /> | |
<span class="String"><span class="String">`</span>pbpaste<span class="String">`</span></span><br /> | |
<span class="Keyword">end</span><br /> | |
<br /> | |
<span class="Keyword">def</span> <span class="Entity">ep</span><br /> | |
<span class="Entity">eval</span>(paste)<br /> | |
<span class="Keyword">end</span><br /> | |
</pre><br /> | |
<br /> | |
Linux with xclip (thanks <a href="http://gist.github.com/124272">Bjørn Arild Mæland</a>):</p> | |
<p> | |
<pre class="sunburst"> | |
<span class="Keyword">def</span> <span class="Entity">copy</span>(<span class="Variable">str</span>) | |
<span class="Variable">IO</span>.<span class="Entity">popen</span>(<span class="String"><span class="String">'</span>xclip -i<span class="String">'</span></span>, <span class="String"><span class="String">'</span>w<span class="String">'</span></span>) { |<span class="Variable">f</span>| f <span class="Keyword"><<</span> str.<span class="Entity">to_s</span> } | |
<span class="Keyword">end</span> | |
<span class="Keyword">def</span> <span class="Entity">paste</span> | |
<span class="String"><span class="String">`</span>xclip -o<span class="String">`</span></span> | |
<span class="Keyword">end</span> | |
</pre> | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mac: | |
<notextile> | |
<pre class="sunburst"> | |
<span class="Comment"><span class="Comment">#</span> stick in .irbrc</span> | |
<span class="Keyword">def</span> <span class="Entity">copy</span>(<span class="Variable">str</span>) | |
<span class="Variable">IO</span>.<span class="Entity">popen</span>(<span class="String"><span class="String">'</span>pbcopy<span class="String">'</span></span>, <span class="String"><span class="String">'</span>w<span class="String">'</span></span>) { |<span class="Variable">f</span>| f <span class="Keyword"><<</span> str.<span class="Entity">to_s</span> } | |
<span class="Keyword">end</span> | |
<span class="Keyword">def</span> <span class="Entity">paste</span> | |
<span class="String"><span class="String">`</span>pbpaste<span class="String">`</span></span> | |
<span class="Keyword">end</span> | |
<span class="Keyword">def</span> <span class="Entity">ep</span> | |
<span class="Entity">eval</span>(paste) | |
<span class="Keyword">end</span> | |
</pre> | |
</notextile> | |
Linux with xclip (thanks "Bjørn Arild Mæland":http://gist.github.com/124272): | |
<notextile> | |
<pre class="sunburst"> | |
<span class="Keyword">def</span> <span class="Entity">copy</span>(<span class="Variable">str</span>) | |
<span class="Variable">IO</span>.<span class="Entity">popen</span>(<span class="String"><span class="String">'</span>xclip -i<span class="String">'</span></span>, <span class="String"><span class="String">'</span>w<span class="String">'</span></span>) { |<span class="Variable">f</span>| f <span class="Keyword"><<</span> str.<span class="Entity">to_s</span> } | |
<span class="Keyword">end</span> | |
<span class="Keyword">def</span> <span class="Entity">paste</span> | |
<span class="String"><span class="String">`</span>xclip -o<span class="String">`</span></span> | |
<span class="Keyword">end</span> | |
</pre> | |
</notextile> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment