<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Voodoo Programming &#187; Terminal</title>
	<atom:link href="http://www.cneophytou.com/tag/terminal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cneophytou.com</link>
	<description>Things programmers do that they know shouldn&#039;t work but they try anyway, and which sometimes actually work, such as recompiling everything.</description>
	<lastBuildDate>Fri, 12 Nov 2010 17:07:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Smooth SSH Passwordless Authentication</title>
		<link>http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/</link>
		<comments>http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 14:36:17 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/</guid>
		<description><![CDATA[This post first appeared on the Voodoo Finance blog which is maintained by my friend Constantinos Michael, and I&#8217;m recreating it here with some extensions so I can find the code more easily when I need it. Using computers remotely is a big part of what I do. Whether I&#8217;m at home and need to [...]]]></description>
			<content:encoded><![CDATA[This post first appeared on the <a href='http://cmichae.acm.jhu.edu/blog/2007/01/18/ssh-passwordless-authentication/'>Voodoo Finance</a> blog which is maintained by my friend <a href='http://cmichae.acm.jhu.edu/'>Constantinos Michael</a>, and I&#8217;m recreating it here with some extensions so I can find the code more easily when I need it.<br />
<br />
Using computers remotely is a big part of what I do. Whether I&#8217;m at home and need to connect to a computer in the lab, or in the lab or the road and need to connect to my home computer. The way I (and pretty much most other linux users) is through SSH. If you&#8217;ve ever had to open more than one ssh connection however, it gets old pretty quickly. First you need to remember the host (and potentially the port, if it&#8217;s not standard) of the machine you&#8217;re connecting to, and also your username on that machine. After those are typed in, you need to enter your password every time you initiate a new connection. Well, all of the above can be automated with a few quick keystrokes in the terminal.<br />
<span id="more-109"></span>
<br />
The first step is to generate an SSH key pair. This private / public key pair will be used to authenticate you on the target machine. As it&#8217;s using an RSA key pair, you can probably leave the passphrase empty as the attacker would first need access to your private key. If you&#8217;re really paranoid, you can type in an easy password (but you&#8217;ll need to type this password in every time you use the key). To generate this key, type the following in a terminal window:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa</pre></div></div>



<p>
After this is done, you&#8217;re ready to install this key on any remote machine you wish to access. Before you do that however, I suggest setting up some aliases to the target machine so you don&#8217;t have to type the host and username every time you wish to log in. To do that, you need to edit (or create) a file called <code>~/.ssh/config</code>. In this file, you can enter a block of text for each host you wish to create an alias for. You can add as many hosts you want, just make sure there&#8217;s an empty line between each configuration. This is an example of what needs to go in this file:</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">host lab
user admin
HostName www.example.com
port 12345</pre></div></div>



<p>
There are many more options that can go in there, and it mostly depends on your setup. But for anything that you don&#8217;t need to specify in the ssh command line, you don&#8217;t need to add an option for in this file. For example with the text I provided above, when you type <code>ssh lab</code> in the command line, it will try to connect to <code>www.example.com</code> using the username <code>admin</code> on port <code>12345</code>. This would be equivalent to typing <code>ssh <span class="oe_textdirection">&#x6d;&#x6f;&#x63;&#x2e;&#x65;&#x6c;&#x70;&#x6d;&#x61;&#x78;&#x65;&#x2e;&#x77;&#x77;&#x77;<span class="oe_displaynone">null</span>&#x40;&#x6e;&#x69;&#x6d;&#x64;&#x61;</span> -oPort=12345</code>. Much easier, isn&#8217;t it?<br />
<br />
Now on to the juicy stuff. Create a script that will install your key on the remote machine. To do that, paste these instructions in the terminal:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key ;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+<span style="color: #c20cb9; font-weight: bold;">w</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;cat ~/.ssh/id_rsa.pub | ssh <span style="color: #000099; font-weight: bold;">\$</span>{1} <span style="color: #000099; font-weight: bold;">\&quot;</span>cat - &gt;&gt; ~/.ssh/authorized_keys<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> \
     <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> a-w+x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ssh-install-key</pre></div></div>



<p>
At this stage, you&#8217;re done with the setup. All you need to do is type</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ssh-install-key lab</pre></div></div>



<p>
in the terminal window (assuming you&#8217;ve set up the above <code>config</code> file with a host called <code>lab</code>), enter  your password as many times as you&#8217;re prompted, and you&#8217;re done! Every subsequent time you wish to connect to this machine, all you need to do is type <code>ssh lab</code>, and you&#8217;re immediately connected, no questions asked! (Unless of course you provided a passphrase for your key pair, in which case you will be prompted for that password).]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/02/05/smooth-ssh-passwordless-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spoofing Leopard&#8217;s MAC address</title>
		<link>http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/</link>
		<comments>http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 19:34:50 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[MAC Address]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/</guid>
		<description><![CDATA[There are many legitimate reasons why someone would want to spoof a system&#8217;s MAC address. In my case, my University binds our network ports to a specific computer&#8217;s MAC address, and only allows you to reset that address once a week. My problems start when I want to switch my two computers for whatever reason, [...]]]></description>
			<content:encoded><![CDATA[There are many legitimate reasons why someone would want to spoof a system&#8217;s MAC address. In my case, my University binds our network ports to a specific computer&#8217;s MAC address, and only allows you to reset that address once a week. My problems start when I want to switch my two computers for whatever reason, and connect my smaller iBook to the wall (let&#8217;s say I want to keep a web server online, but wish to take my MacBook Pro on the road).<br />
<span id="more-106"></span>
<br />
In Tiger, it was very easy to spoof a MAC address:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> en0 ether 00:00:00:00:00:00</pre></div></div>



<p>
where <code>en0</code> is the network interface you wish to change the MAC address of, and <code>00:00:00:00:00:00</code> is the target MAC address. With Leopard, that line no longer works. No matter how much I searched, I couldn&#8217;t find a solid alternative. Turns out, it&#8217;s extremely simple:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ifconfig</span> en0 lladdr 00:00:00:00:00:00</pre></div></div>



<p>
That&#8217;s it!<br />
<strong>Note:</strong> This has been tested under 10.5.1 with both en0 and en1, and at least for the wired interface it works as advertised.]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/01/19/spoofing-leopards-mac-address/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		</item>
		<item>
		<title>Bandwidth throttling in OS X</title>
		<link>http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/</link>
		<comments>http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 14:27:52 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/</guid>
		<description><![CDATA[It&#8217;s been a while since my last post, and that&#8217;s because I&#8217;ve been busy with coursework, so I haven&#8217;t had time to mess around with OS X. However there was one feature I needed to figure out out of necessity if anything else. I have certain files I wish to freely share with some friends [...]]]></description>
			<content:encoded><![CDATA[It&#8217;s been a while since my last post, and that&#8217;s because I&#8217;ve been busy with coursework, so I haven&#8217;t had time to mess around with OS X. However there was one feature I needed to figure out out of necessity if anything else. I have certain files I wish to freely share with some friends of mine, and the easiest way for me to do that was put them on my local web server and serve them over http. The only problem with this approach, is that the university has a weekly data transfer limit of 5Gb per week during peak hours, those being between 6pm and midnight. Additionally, local traffic doesn&#8217;t count towards that limit, and if that limit is exceeded then my Internet would be blocked and limited to only the local network for the remainder of that week.<br />
<br />
Therefore, the solution I was looking for would not require me to turn off my web server (as I&#8217;d like to still access it locally), and would ideally simply limit the outgoing traffic automatically between those two times.<br />
<span id="more-105"></span>
<br />
One aspect that made this particular solution usable, was the fact that port 80 is firewalled from the external world. This means that if I want to run a web server on my local machine accessible from the outside, I have to do it on a different port. Therefore I use port 80 to access the web server locally, and port 8080 to access it from the outside. This gives me a dedicated point of entry for the traffic that I wish to limit the bandwidth.<br />
<br />
The solution is fairly simple, and involves only two tools: <code>cron</code>, for enabling and disabling the filter at specific times, and <code>ipfw</code> for actually setting up the filters. The idea is this: create a <code>pipe</code> using <code>ipfw</code> that limits outgoing traffic on port 8080 to a specified rate (let&#8217;s say 15KByte/s), and using a cron job add the pipe to my network interface at 6pm, and delete it at midnight. That&#8217;s it! Theoretically you only have to create the pipe once, but in order to have this survive across restarts, I added another cron job at 5:59pm that re-creates the pipe. The full contents of the crontab file (located at <code>/etc/crontab</code>) are as follows:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Set the bandwidth limit at 5:59pm</span>
<span style="color: #000000;">59</span> <span style="color: #000000;">17</span>	<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>	root	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ipfw pipe <span style="color: #000000;">1</span> config bw 15KByte<span style="color: #000000; font-weight: bold;">/</span>s
<span style="color: #666666; font-style: italic;"># Add the bandwidth limit to the specified port at 6:00pm</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">18</span>	<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>	root	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ipfw add <span style="color: #000000;">1</span> pipe <span style="color: #000000;">1</span> src-port <span style="color: #000000;">8080</span>
<span style="color: #666666; font-style: italic;"># Lift the bandwidth limit at 12:00am</span>
<span style="color: #000000;">0</span> <span style="color: #000000;">0</span>	<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>	root	<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ipfw delete <span style="color: #000000;">1</span></pre></div></div>



<p>
The problem with this is if the computer boots up or reboots after 6pm and before midnight, the filters will not be set. The solution is to use <code>anacron</code> for executing the ipfw commands, But as I rarely shut down or reboot my computer, it wasn&#8217;t worth it for me to make that happen. If I do make those modifications, I will post an update here. Also note that the ipfw commands need to be executed as root.<br />]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2008/01/19/bandwidth-throttling-in-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hints and code snippets for a more sane OS X Terminal experience</title>
		<link>http://www.cneophytou.com/2006/11/13/hints-and-code-snippets-for-a-more-sane-os-x-terminal-experience/</link>
		<comments>http://www.cneophytou.com/2006/11/13/hints-and-code-snippets-for-a-more-sane-os-x-terminal-experience/#comments</comments>
		<pubDate>Mon, 13 Nov 2006 11:06:56 +0000</pubDate>
		<dc:creator>Constantinos</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cneophytou.com/2006/11/13/hints-and-code-snippets-for-a-more-sane-os-x-terminal-experience/</guid>
		<description><![CDATA[Pretty long title, huh? Well, I&#8217;ve finally made the decision that there&#8217;s no way I&#8217;ll ever be able to keep a journal. So instead, I&#8217;ll start posting code snippets and general hints that I mostly harvested online (and try to cite wherever I can &#8211; remember that is -), but also modified to suit my [...]]]></description>
			<content:encoded><![CDATA[Pretty long title, huh? Well, I&#8217;ve finally made the decision that there&#8217;s no way I&#8217;ll ever be able to keep a journal. So instead, I&#8217;ll start posting code snippets and general hints that I mostly harvested online (and try to cite wherever I can &#8211; remember that is -), but also modified to suit my purposes&#8230; First up is seamless integration of X11 in OS X with the Terminal application.. Read on for the code<br />
<span id="more-71"></span>
<br />
First off, the reason I got started in this: I HATE xterm. Really dislike it, to the point where I would actively avoid any xwindow apps. That&#8217;s until I came across <a href='http://www.macosxhints.com/article.php?story=2005091004025818&#038;query=x11%2Bterminal'>this hint</a> at <a href='http://www.macosxhints.com'>macosxhints.com</a>. Really nice hint, but to get the best possible approach you have to shift through all the comments, and merge some bash with some csh scripts in order to get the most seamless approach. So this is my solution, for the bash shell, derived from that hint on macosxhints, and explicitly avoiding any modifications of master files (which might get overwritten with an OS X upgrade).<br />
<br />
First step, is to prevent X11 from opening up an xterm window. That&#8217;s fairly easy. Simply create a file called <code>.xinitrc</code> under your home (<code>~/</code>) directory with your favorite editor (like <a href='http://macromates.com/'>TextMate</a> <img src='http://www.cneophytou.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ), and paste this code in it (lifted straight off the <a href='http://www.macosxhints.com/article.php?story=2005091004025818&#038;query=x11%2Bterminal'>aforementioned hint</a>):<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>X11R6<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># surpress starting of an initial xterm</span>
xterm<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># remember the display name</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DISPLAY</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.tmp<span style="color: #000000; font-weight: bold;">/</span>X11-display-<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span> -s<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># run system-defined xinitrc (doesn't return)</span>
<span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>X11<span style="color: #000000; font-weight: bold;">/</span>xinit<span style="color: #000000; font-weight: bold;">/</span>xinitrc</pre></div></div>




<p>
Now what this does, is redefine the function that calls up the xterm window, and make it do nothing. Then the master file is sourced, so no harm no foul. This modification will survive across upgrades too.<br />
<br />
Now to the more tricky part. In your <code>.bash_profile</code> file, insert this little gem of a code:<br />
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span><span style="color: #007800;">$DISPLAY</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span><span style="color: #007800;">$SSH_TTY</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span><span style="color: #007800;">$REMOTEHOST</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">DISPLAY</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> xw <span style="color: #660033;">-o</span> <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'/^\/.*X11.*\:/s/.*:/:/p'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$DISPLAY</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">if</span> xwininfo <span style="color: #660033;">-display</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DISPLAY</span>&quot;</span> <span style="color: #660033;">-root</span> <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> Using X11 display <span style="color: #007800;">$DISPLAY</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> DISPLAY
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">unset</span> DISPLAY
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>



<p>
<br />
This piece of code simply tries to capture the $DISPLAY given by X11, so it can be used in the Terminal. This is usually <code>:0</code>, but not if you&#8217;re running it over ssh. This should catch either.<br />
<br />
So far so good. Whenever I need xwindows, I can start X11, then open a new terminal window and voila. But wait a minute. Why would I have to manually start X11? When that app is idle, it&#8217;s using up almost zero resources. I could very easily place it in my startup items. That&#8217;s a good solution, with the problem being that I rarely need X11, and I don&#8217;t want to have it in my dock all the time.<br />
<br />
This is where the magic happens (btw this same method can be used to hide the dock and menu-bar of pretty much ANY app). Find the X11 app in the finder under <code>/Applications/Utilities/</code>. Ctrl-click on it, and &#8220;Show Package Contents&#8221;. Then navigate to <code>Contents/Info.plist</code>, open it up in the Property List Editor, and add a new sibling under Root called <code>LSUIElement</code>, set it to boolean, and give it the value &#8216;Yes&#8217; (or set it to string and give it the value 1). Save the plist file, and close it.<br />
<br />
Almost there. Now in the terminal, give the command <code>touch /Applications/Utilities/X11.app/</code>, and you&#8217;re all set. Double click on the X11 app to start it, and&#8230; nothing! The only way you can know it&#8217;s running, is if you look for it in the Activity Monitor! This won&#8217;t survive across upgrades of X11, and in fact if X11 gets upgraded you <em>will</em> have to open Activity Monitor to kill it before the upgrade, but I feel it&#8217;s an easy change to make, and a change that&#8217;s almost a second nature to me.<br />
<br />
So that&#8217;s my solution for this. Right now I have X11 running in the background at all times, and terminal simply captures the display and uses it whenever it needs it. And since all the modified files are in the user&#8217;s home directory, this solution will survive across OS upgrades. As a final note, I do have the capture script for tcsh, but it&#8217;s the same as the script listed in a comment of the previously mentioned macosxhints hint, so I won&#8217;t enter it here again. Just look for it there.]]></content:encoded>
			<wfw:commentRss>http://www.cneophytou.com/2006/11/13/hints-and-code-snippets-for-a-more-sane-os-x-terminal-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

