<?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"
	>

<channel>
	<title>Simon Gregory</title>
	<atom:link href="http://blog.simongregory.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.simongregory.com</link>
	<description>Flash, Flex and TextMate</description>
	<pubDate>Tue, 04 Mar 2008 14:58:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Apache Bundle Upgrade</title>
		<link>http://blog.simongregory.com/02/apache-bundle-upgrade/</link>
		<comments>http://blog.simongregory.com/02/apache-bundle-upgrade/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 22:23:21 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<category><![CDATA[TextMate]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[bundle]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/02/apache-bundle-upgrade/</guid>
		<description><![CDATA[The Apache bundle, which I originally contributed in the early days of TextMate, was due an upgrade. So I&#8217;ve made a few improvements&#8230; 
Start, Stop, Restart and Graceful commands (⌘R)
These commands, which all target apachectl, are now bound to ⌘R under the source.apache-config scope which makes it more convenient to directly control httpd from TextMate. [...]]]></description>
			<content:encoded><![CDATA[<p>The Apache bundle, which I originally contributed in the early days of TextMate, was due an upgrade. So I&#8217;ve made a few improvements&#8230; </p>
<h2>Start, Stop, Restart and Graceful commands (⌘R)</h2>
<p>These commands, which all target apachectl, are now bound to ⌘R under the source.apache-config scope which makes it more convenient to directly control httpd from TextMate. </p>
<p>As apachectl requires sudo privileges I used applescript for authentication. For reasons only known to Apple the password request dialog would launch but not get focus - leaving you to reach for the mouse to target the input field. Moving away from the keyboard is slow so this was something that really annoyed me. I&#8217;ve now switched to using the excellent <a href="http://macromates.com/blog/2006/new-dialog-system-for-commands/" title="TextMate Dialog System">tm_dialog</a> system which makes things much smoother.</p>
<p>It is also possible to store your admin password in your Keychain, this is done by selecting the &#8220;Add to Keychain&#8221; toggle in the password request dialog box. I&#8217;m more than happy with the security implications of this as I&#8217;m fairly good at keeping my machines locked. If you do choose to do this then the command line security app will have access to the keychain item and is the only way someone could gain access. </p>
<h2>Documentation (⌃H)</h2>
<p>This now searches a documentation index file for the current word/selection then redirects or presents a list of matches as appropriate. If you appear to have the documentation installed locally then the script favours it over the apache website.</p>
<h2>Open Include (⇧⌘D)</h2>
<p>The language definition has been improved to add a scope for Includes. Using the key combination apple-shift-D on this scope opens the file referenced by the inlcude, or directory if it is wild carded.</p>
<h2>Open Config&#8230; (⇧⌘C)</h2>
<p>Previously there were various commands to open the apache.conf files these have now been consolidated into one command which searches the apache install directory, either <code>/etc/apache2</code> or  <code>/private/etc/httpd</code> depending on your version of OS X and the <code>/users</code>, <code>/extra</code> and <code>/other</code> subdirectories. All the conf files found are presented in pop-up from which  one can be choosen to open.</p>
<h2>Bundle Configuration</h2>
<p>It is now possible to override the default bundle behaviour by setting the following environmental variables. <code>TM_APACHE_DIRECTORY</code>, <code>TM_APACHE_ACCESS_LOG</code>, <code>TM_APACHE_ERROR_LOG</code> and<br />
<code>TM_APACHE_MANUAL_URI</code> all allow the custom targeting of files and directories. See the bundle help for a detailed explanation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/02/apache-bundle-upgrade/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Open Bundle as Project&#8230;</title>
		<link>http://blog.simongregory.com/01/open-bundle-as-project/</link>
		<comments>http://blog.simongregory.com/01/open-bundle-as-project/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 10:30:13 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[TextMate]]></category>

		<category><![CDATA[bundle]]></category>

		<category><![CDATA[bundle development]]></category>

		<category><![CDATA[command]]></category>

		<category><![CDATA[tip]]></category>

		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/01/open-bundle-as-project/</guid>
		<description><![CDATA[I&#8217;m often opening the bundles I develop - and nosing through the others - as projects, and doing so via the Finder or the File > Open menu is long winded. To speed up the process here&#8217;s a small command which searches the default bundle locations and presents all the bundles in a dialog. Pick [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m often opening the bundles I develop - and nosing through the others - as projects, and doing so via the Finder or the File > Open menu is long winded. To speed up the process here&#8217;s a small command which searches the default bundle locations and presents all the bundles in a dialog. Pick the one you&#8217;re interested in and TextMate opens it as a project. That&#8217;s if it&#8217;s enabled, when it&#8217;s not the default behavior is to enable it, second time round it will open as a project.</p>
<p><a href="/wp-content/assets/commands/Open_Bundle_as_Project___.tmCommand.zip" title="Open Bundle as Project Command"><span class="shift_for_inline_32">Download </span><img src="/wp-content/assets/images/tm/tm_commands_32x32.png" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/01/open-bundle-as-project/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HelvectorLight Theme</title>
		<link>http://blog.simongregory.com/12/helvectorlight-theme/</link>
		<comments>http://blog.simongregory.com/12/helvectorlight-theme/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 00:28:11 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[TextMate]]></category>

		<category><![CDATA[language definition]]></category>

		<category><![CDATA[syntax colouring]]></category>

		<category><![CDATA[tmtheme]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/12/helvectorlight-theme/</guid>
		<description><![CDATA[I&#8217;ve just updated the ActionScript 3 Bundle to include an ASDoc language definition. This is essentially a scope change of Luke Daley&#8217;s JavaDoc language definition. The result is that the following scopes within the documentation blocks are brought under new colour jurisdictions.  
keyword.other
entity.name.tag
punctuation.definition.tag
For me, using my favourite theme - Twilight - the extra colour [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just updated the ActionScript 3 Bundle to include an ASDoc language definition. This is essentially a scope change of Luke Daley&#8217;s JavaDoc language definition. The result is that the following scopes within the documentation blocks are brought under new colour jurisdictions.  </p>
<p><code>keyword.other</code><br />
<code>entity.name.tag</code><br />
<code>punctuation.definition.tag</code></p>
<p>For me, using my favourite theme - Twilight - the extra colour where I was so used to seeing grey wasn&#8217;t working. To combat it, and get things greyscale again, I added 3 new theme elements and applied them to the following scopes:</p>
<p><code>comment.block.documentation keyword.other</code><br />
<code>comment.block.documentation entity.name.tag</code><br />
<code>comment.block.documentation punctuation.definition.tag</code></p>
<p>The results are the <a href="/wp-content/assets/themes/HelvectorLight.tmTheme.zip">HelvectorLight.tmTheme</a> which calms things down again.</p>
<p><a href="/wp-content/assets/themes/HelvectorLight.tmTheme.zip"><span class="shift_for_inline_32">Download </span><img src="/wp-content/assets/images/tm/theme_32x32.png"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/12/helvectorlight-theme/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Installing the Debug Flash Player on Multiple User Accounts</title>
		<link>http://blog.simongregory.com/12/installing-the-debug-flash-player-on-multiple-user-accounts/</link>
		<comments>http://blog.simongregory.com/12/installing-the-debug-flash-player-on-multiple-user-accounts/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 15:08:11 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<category><![CDATA[OS X]]></category>

		<category><![CDATA[flash player debug install problems]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/12/installing-the-debug-flash-player-on-multiple-user-accounts/</guid>
		<description><![CDATA[I share one of my development machines with another flash developer and have run into a problem whereby the debug flash player was only available to the user who installed it. Trying to set more generous permissions on the plug-in didn&#8217;t work. So I simply changed the name of the plug-in by prefixing it with [...]]]></description>
			<content:encoded><![CDATA[<p>I share one of my development machines with another flash developer and have run into a problem whereby the debug flash player was only available to the user who installed it. Trying to set more generous permissions on the plug-in didn&#8217;t work. So I simply changed the name of the plug-in by prefixing it with the installing users name then reinstalled it as second user. This leaves you with multiple instances of the flash player in <code>Library/Internet Plug-Ins</code> but as each user only has permission to use the player they installed no confusion arises. </p>
<p>The most recent debug player can be found <a href="http://www.adobe.com/support/flashplayer/downloads.html">here</a>. An archive of debug players can be found <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266&#038;sliceId=1">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/12/installing-the-debug-flash-player-on-multiple-user-accounts/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TextMate Ant Bundle</title>
		<link>http://blog.simongregory.com/10/textmate-ant-bundle/</link>
		<comments>http://blog.simongregory.com/10/textmate-ant-bundle/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 22:40:03 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/10/textmate-ant-bundle/</guid>
		<description><![CDATA[Following on from my work with the Apache, ActionScript, ActionScript 3 and Flex TextMate Bundles, comes a bundle for the Ant build system. It is available for checkout here which I&#8217;d recommend for the most up to date version, or download as a zip here.
Ant Bundle 
]]></description>
			<content:encoded><![CDATA[<p>Following on from my work with the <a href="http://apache.org/">Apache</a>, ActionScript, ActionScript 3 and Flex <a href="http://macromates.com">TextMate</a> Bundles, comes a bundle for the <a href="http://ant.apache.org/">Ant</a> build system. It is available for checkout <a href="http://macromates.com/svn/Bundles/trunk/Review/Bundles/">here</a> which I&#8217;d recommend for the most up to date version, or download as a zip <a href="/wp-content/assets/bundles/Ant.tmbundle.zip" >here</a>.</p>
<p><a href="/wp-content/assets/bundles/Ant.tmbundle.zip" title="Ant.tmbundle"><span class="shift_for_inline_bundle_icon_32">Ant Bundle </span><img src="/wp-content/assets/images/tm/tm_bundle_32x32.png"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/10/textmate-ant-bundle/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TextMate ActionScript 3 and Flex Bundles</title>
		<link>http://blog.simongregory.com/10/textmate-actionscript-3-and-flex-bundles/</link>
		<comments>http://blog.simongregory.com/10/textmate-actionscript-3-and-flex-bundles/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 22:21:49 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[TextMate]]></category>

		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Ant]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/10/textmate-actionscript-3-and-flex-bundles/</guid>
		<description><![CDATA[As a Flash developer who&#8217;s been working with Flex and ActionScript 3 since late last year I really couldn&#8217;t bring myself to use the Flex Builder Eclipse plug-in. This down to my addiction to TextMate, in my opionion it simply out classes the competion. As a result I&#8217;m responsible for TextMate&#8217;s ActionScript 3 and Flex [...]]]></description>
			<content:encoded><![CDATA[<p>As a Flash developer who&#8217;s been working with Flex and ActionScript 3 since late last year I really couldn&#8217;t bring myself to use the <a href="http://www.adobe.com/products/flex/flexbuilder/">Flex Builder</a> <a href="http://www.eclipse.org/">Eclipse</a> plug-in. This down to my addiction to <a href="http://macromates.com">TextMate</a>, in my opionion it simply out classes the competion. As a result I&#8217;m responsible for <a href="http://macromates.com/">TextMate&#8217;s</a> ActionScript 3 and Flex bundles.</p>
<p>At the moment the bundles are in the review section of the TextMate <a href="http://macromates.com/svn/Bundles/trunk/Review/Bundles/">Repository</a>. Once installed the bundle help covers how to set up (primarily to download the <a href="http://www.adobe.com/products/flex/downloads/">flex sdk</a>) and outlines the non-obvious commands. </p>
<p>The main highlights of the bundles are:</p>
<li>MXMLC and FCSH Build Commands.</li>
<li>Function, Tag, Import Auto Completion.</li>
<li>ActionScript 3 and Flex documentation search.</li>
<li>Drag and Drop of imports, includes, embed assets, css, xml.</li>
<li>ASDoc Support.</li>
<li>MXML Validation.</li>
<li>Manifest Generation.</li>
<li>Class and Component Templates.</li>
<li>Flex Builder compatible project creation.</li>
<li>Unused Import statement removal.</li>
<li>Shortcut Key Super Class, Code Behind and Import file opening.</li>
<p>Thanks to the following people who have all had a hand, although they may not know it, in the creation of the bundles:</p>
<li><a href="http://blog.danielparnell.com/">Daniel Parnell</a></li>
<li><a href="http://blog.iconara.net/">Theo Hultberg</a></li>
<li><a href="http://www.dirtystylus.com/blog/">Mark Llobrera</a></li>
<li><a href="http://www.4d.be/">Joachim</a></li>
<li>ChromaticRain</li>
<li><a href="http://subtlegradient.com/">Thomas Aylott</a></li>
<p>For those of you who don&#8217;t use subversion the following zip&#8217;s can be downloaded, but they won&#8217;t necessarily be the latest version :</p>
<p><a href="/wp-content/assets/bundles/ActionScript%203.tmbundle.zip" title="ActionScript 3.tmbundle"><span class="shift_for_inline_bundle_icon_32">ActionScript 3 Bundle </span><img src="/wp-content/assets/images/tm/tm_bundle_32x32.png"/></a><br />
<a href="/wp-content/assets/bundles/Flex.tmbundle.zip" title="Flex.tmbundle"><span class="shift_for_inline_bundle_icon_32">Flex Bundle </span><img src="/wp-content/assets/images/tm/tm_bundle_32x32.png"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/10/textmate-actionscript-3-and-flex-bundles/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using svnX via svn-ssh</title>
		<link>http://blog.simongregory.com/02/how-to-svnx-svn-ssh/</link>
		<comments>http://blog.simongregory.com/02/how-to-svnx-svn-ssh/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 10:15:42 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/?p=20</guid>
		<description><![CDATA[This is a relatively simple thing to do, and it&#8217;s really all about setting up shh rather than svn, but when you don&#8217;t quite understand what is happening it&#8217;s a little creepy having the authentication handled automatically. The shh authentication process uses a public / private key system which is explained nicely here.
To start you [...]]]></description>
			<content:encoded><![CDATA[<p>This is a relatively simple thing to do, and it&#8217;s really all about setting up shh rather than svn, but when you don&#8217;t quite understand what is happening it&#8217;s a little creepy having the authentication handled automatically. The shh authentication process uses a public / private key system which is explained nicely <a href="http://en.wikipedia.org/wiki/Secure_Shell#How_ssh_uses_public-key_cryptography_.28with_analogy.29 ">here</a>.</p>
<p>To start you need ssh to use keys rather than passwords. This is because subversion needs to &#8220;transparently&#8221; authenticate each time you make a request. I hope I&#8217;m right in thinking that it opens a tunnel to the remote machine and invokes the service as a <code>svnserve</code> process there.</p>
<p>So, open a terminal window and type <code>ssh-keygen -d</code> to generate your public and private ssh keys. Hit return at each prompt to stick with the default options. You&#8217;ll end up with two files called <code>id_dsa.pub</code> and <code>id_dsa</code> in your <code>pwd</code> move the files to <code>~/.ssh/</code>. Then you need to copy the contents of <code>id_dsa.pub</code> to this file <code>~/.ssh/authorized_keys</code> on your remote machine ( the one hosting the subversion repository) - creating it if it doesn&#8217;t exist. You can append more than one public key to the authorized_keys file if you’re connecting from more than one machine. If you have access to more than one user account on the the remote machine then you need to copy the key into each users <code>authorized_keys</code> file.  I used <a href="http://cyberduck.ch/">CyberDuck</a> along with a sftp connection to get the onto the remote machine. You should then be able to login to the remote machine using <code>username@server.org</code>.</p>
<p>Once you&#8217;ve got the ssh connection verified it should be plain sailing with svnx. You&#8217;ll be able ot use your repository with the following</p>
<p><code>svn+ssh://username@domain.com/path/to/repository</code></p>
<p>I&#8217;ve just found <a href="http://macromates.com/blog/archives/2005/11/06/subversion-support-and-ssh-key-pairs/">this</a> on the <a href="http://macromates.com/blog/">TextMate</a> blog. It&#8217;s covering the same ssh key generation process, but using the command line completely, and describing how to set up ssh aliases to save a little bit of typing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/02/how-to-svnx-svn-ssh/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Terminal to Finder</title>
		<link>http://blog.simongregory.com/01/terminal-to-finder/</link>
		<comments>http://blog.simongregory.com/01/terminal-to-finder/#comments</comments>
		<pubDate>Mon, 22 Jan 2007 12:12:38 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/?p=19</guid>
		<description><![CDATA[I&#8217;ve been using the terminal more and more and began to find the process of nipping back and forth between it (at the pwd) and the Finder a little tedious, typing:
open -a "Finder.app" .
was hardly difficult but I figured that it would be handy to shorten it down to simply typing finder. To do this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using the terminal more and more and began to find the process of nipping back and forth between it (at the pwd) and the Finder a little tedious, typing:</p>
<p><code>open -a "Finder.app" .</code></p>
<p>was hardly difficult but I figured that it would be handy to shorten it down to simply typing <code>finder</code>. To do this I&#8217;d imagined that I&#8217;d have to create a binary executable for one of the bin folders. Thankfully it was simpler than that, it&#8217;s possible to put plain old shell scripts in the bin folders and have them execute. So in <code>/usr/local/bin</code> I created a file called <code>finder</code>, inside which I put the following:</p>
<p><code>#!/bin/bash</code><br />
<code><br />
open -a "Finder.app" .<br />
exit 0;<br />
</code></p>
<p><code>chmod 755</code> the file and it worked. The only other thing you may need to do is make sure that you have the following line :</p>
<p><code>export PATH="$PATH:/usr/local/bin"</code> </p>
<p>in your shell profile <code>~/.profile</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/01/terminal-to-finder/feed/</wfw:commentRss>
		</item>
		<item>
		<title>svn ignore</title>
		<link>http://blog.simongregory.com/01/svn-ignore/</link>
		<comments>http://blog.simongregory.com/01/svn-ignore/#comments</comments>
		<pubDate>Sat, 20 Jan 2007 14:57:51 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/?p=18</guid>
		<description><![CDATA[How do you get subversion to ingnore certain files? It can be done globally or on a per directory basis.
For global ignores find your subversion config file. For me this was here ~/.subversion/config then edit the following line, here I&#8217;ve added *.tmproj to ignore any file which ends with .tmproj (the * being a reg [...]]]></description>
			<content:encoded><![CDATA[<p>How do you get subversion to ingnore certain files? It can be done globally or on a per directory basis.</p>
<p>For global ignores find your subversion config file. For me this was here <code>~/.subversion/config</code> then edit the following line, here I&#8217;ve added *.tmproj to ignore any file which ends with .tmproj (the * being a reg exp for any prefix).</p>
<p><code>global-ignores = *.o *.lo *.la #*# .*.rej *.tmproj</code></p>
<p>To ingnore files on a per directory basis <code>cd</code> to the directory in question and use the following.</p>
<p><code>svn propset svn:ignore "*.cache" .</code></p>
<p>This will apply the ignore to the file or files specifed by the pattern. In this case all files ending with .cache. The trialing . applies the ignore to the current directory, but can be the path to any subversion directory. The command above creates a .svn/dir-props file with the following contents in the specified directory.</p>
<p><code>K 10<br />
svn:ignore<br />
V 8<br />
*.cache</code></p>
<p><code>END</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/01/svn-ignore/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Keychain Access from a Shell.sh Script</title>
		<link>http://blog.simongregory.com/01/keychain-access-from-a-shellsh-script/</link>
		<comments>http://blog.simongregory.com/01/keychain-access-from-a-shellsh-script/#comments</comments>
		<pubDate>Wed, 17 Jan 2007 12:29:49 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
		
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://blog.simongregory.com/?p=16</guid>
		<description><![CDATA[Here&#8217;s a useful snippet to enable you to securely store passwords in OS X&#8217;s keychain and use them in a shell scripts.
#!/bin/bash

PASSWORD=`exec osascript &#60;&#60;EOF &#124; tr &#8220;\r&#8221; &#8220;\n&#8221;

    (*
     To use the Keychain to store the admin password then 

     Open /Applications/Utilities/Keychain Access.app
  [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a useful snippet to enable you to securely store passwords in OS X&#8217;s keychain and use them in a shell scripts.</p>
<pre class="textmate-source"><span class="source source_shell"><span class="comment comment_line comment_line_number-sign comment_line_number-sign_shell"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_shell">#</span>!/bin/bash
</span>
PASSWORD=<span class="string string_interpolated string_interpolated_backtick string_interpolated_backtick_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">`</span>exec osascript &lt;&lt;EOF | tr &#8220;\r&#8221; &#8220;\n&#8221;

<span class="source source_applescript">    <span class="comment comment_block comment_block_applescript"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_applescript">(*</span>
     To use the Keychain to store the admin password then 

     Open /Applications/Utilities/Keychain Access.app
     Add a new keychain called &#8220;TM&#8221;
     Add a Key with the name &#8220;test&#8221; and store your password in it.

     I&#8217;d recommend learning how keychains work then tailoring
     the process to your security needs.
    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_applescript">*)</span></span>

<span class="meta meta_tell-block meta_tell-block_application meta_tell-block_application_generic meta_tell-block_application_generic_applescript">    <span class="keyword keyword_control keyword_control_applescript">tell</span> <span class="support support_class support_class_built-in support_class_built-in_applescript">application</span> <span class="string string_quoted string_quoted_double string_quoted_double_application-name string_quoted_double_application-name_applescript"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;</span>Keychain Scripting<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;</span></span>
        <span class="keyword keyword_control keyword_control_applescript">set</span> myKeyChain <span class="keyword keyword_control keyword_control_applescript">to</span> keychain <span class="string string_quoted string_quoted_double string_quoted_double_applescript"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;</span>TM.keychain<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;</span></span>
        <span class="keyword keyword_control keyword_control_applescript">set</span> theKeyList <span class="keyword keyword_control keyword_control_applescript">to</span> <span class="keyword keyword_control keyword_control_reference keyword_control_reference_applescript">every</span> key <span class="keyword keyword_control keyword_control_reference keyword_control_reference_applescript">of</span> myKeyChain
        <span class="keyword keyword_control keyword_control_applescript">set</span> thePassword <span class="keyword keyword_control keyword_control_applescript">to</span> <span class="string string_quoted string_quoted_double string_quoted_double_applescript"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;&#8221;</span></span>
        <span class="keyword keyword_control keyword_control_applescript">repeat with</span> x <span class="keyword keyword_control keyword_control_applescript">from</span> <span class="constant constant_numeric constant_numeric_applescript">1</span> <span class="keyword keyword_control keyword_control_applescript">to</span> <span class="punctuation punctuation_section punctuation_section_group punctuation_section_group_applescript">(</span>length <span class="keyword keyword_control keyword_control_reference keyword_control_reference_applescript">of</span> theKeyList<span class="punctuation punctuation_section punctuation_section_group punctuation_section_group_applescript">)</span>
            <span class="keyword keyword_control keyword_control_applescript">set</span> theKey <span class="keyword keyword_control keyword_control_applescript">to</span> <span class="support support_class support_class_standard-suite support_class_standard-suite_applescript">item</span> x <span class="keyword keyword_control keyword_control_reference keyword_control_reference_applescript">of</span> theKeyList
            <span class="keyword keyword_control keyword_control_applescript">if</span> the <span class="support support_constant support_constant_standard-suite support_constant_standard-suite_applescript">name</span> <span class="keyword keyword_control keyword_control_reference keyword_control_reference_applescript">of</span> theKey <span class="keyword keyword_operator keyword_operator_applescript">is</span> <span class="string string_quoted string_quoted_double string_quoted_double_applescript"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;</span>test<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_applescript">&#8220;</span></span> <span class="keyword keyword_control keyword_control_applescript">then</span>
                <span class="keyword keyword_control keyword_control_applescript">set</span> thePassword <span class="keyword keyword_control keyword_control_applescript">to</span> password <span class="keyword keyword_control keyword_control_reference keyword_control_reference_applescript">of</span> theKey
                <span class="comment comment_line comment_line_double-dash comment_line_double-dash_applescript"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_applescript">&#8211;</span>exit repeat leaves us without
</span>                <span class="comment comment_line comment_line_double-dash comment_line_double-dash_applescript"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_applescript">&#8211;</span>a value returned to the shell script&#8230;
</span>            <span class="keyword keyword_control keyword_control_applescript">end if</span>
        <span class="keyword keyword_control keyword_control_applescript">end repeat</span>
    <span class="keyword keyword_control keyword_control_applescript">end tell</span></span></span></span>

EOF<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">`</span></span>

echo <span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">&#8220;</span><span class="variable variable_other variable_other_normal variable_other_normal_shell"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_shell">$</span>PASSWORD</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">&#8220;</span>

exit 0<span class="keyword keyword_operator keyword_operator_list keyword_operator_list_shell">;</span></span></pre>
<p><a href="/wp-content/assets/code/bash/keychainSnippet.sh" title="keychainSnippet.sh"><span class="shift_for_inline_32">Download: </span><img src="/wp-content/assets/images/tm/shell_32x32.png"/></a></p>
<p><em>Update</em>: As of Leopard it is now possible to do this via the command line tool <code>security</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.simongregory.com/01/keychain-access-from-a-shellsh-script/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.432 seconds -->
