{"id":692,"date":"2009-03-04T13:42:34","date_gmt":"2009-03-04T21:42:34","guid":{"rendered":"http:\/\/www.curlybrace.com\/words\/2009\/03\/04\/command-line-autocompletion-for-os-x\/"},"modified":"2011-03-07T00:28:01","modified_gmt":"2011-03-07T08:28:01","slug":"command-line-autocompletion-for-os-x","status":"publish","type":"post","link":"https:\/\/www.curlybrace.com\/words\/2009\/03\/command-line-autocompletion-for-os-x\/","title":{"rendered":"Making OS X Command Line Behave More Like Linux (GNU)"},"content":{"rendered":"<p>The command-line oddities of Mac OS X&#8217;s BSD heritage drive me insane.  I much prefer the behavior of the GNU toolchain, as provided by Ubuntu Linux.<\/p>\n<p>To begin, first <a href=\"http:\/\/www.macports.org\/install.php\">install MacPorts<\/a>.<\/p>\n<h3>MacPorts Installation Variant <tt>+with_default_names<\/tt><\/h3>\n<p>With several MacPorts packages, the <tt>+with_default_names<\/tt> variant may be specified.  This causes package contents to be installed without the default &#8220;g&#8221; prefix.  For example, without <tt>+with_default_names<\/tt>, <tt>find<\/tt> would be installed as <tt>gfind<\/tt>.<\/p><\/blockquote>\n<h3>Autocompletion<\/h3>\n<p>1) Use MacPorts to install the <tt>bash-completion<\/tt> package:<\/p>\n<blockquote>\n<pre class=\"bash\">sudo \/opt\/local\/bin\/port install bash-completion<\/pre>\n<\/blockquote>\n<p>2)  Edit <tt>~\/.bash_profile<\/tt> to load the correct autocompletion script:<\/p>\n<blockquote>\n<pre class=\"bash\">if [ -f <b>\/opt\/local\/<\/b>etc\/bash_completion ]; then\r\n   \/opt\/local\/etc\/bash_completion\r\nfi<\/pre>\n<\/blockquote>\n<p>Open a new terminal window, and commands should auto-complete according to the GNU specification.<\/p>\n<h3>Find<\/h3>\n<p>The GNU version of <tt>find<\/tt> helpfully assumes that, if no arguments were given, you wish to search the current directory.  The OS X (BSD) version has no idea what to do without a directory specification.<\/p>\n<blockquote>\n<pre class=\"bash\">sudo \/opt\/local\/bin\/port install findutils +with_default_names<\/pre>\n<\/blockquote>\n<p>This package includes find<\/tt>, <tt>gfind<\/tt>, <tt>glocate<\/tt>, <tt>goldfind<\/tt>, <tt>gupdatedb<\/tt>, <tt>gxargs<\/tt>, <tt>locate<\/tt>, <tt>oldfind<\/tt>, <tt>updatedb<\/tt>, and <tt>xargs<\/tt>.<\/p>\n<h3>Core Utilities<\/h3>\n<p>This vaguely-named package provides a large number of standard GNU tools.<\/p>\n<blockquote>\n<pre class=\"bash\">sudo \/opt\/local\/bin\/port install coreutils +with_default_names<\/pre>\n<\/blockquote>\n<h3>Update Path<\/h3>\n<p>In order to call the MacPorts-installed tools by default, your path will have to be updated to include <tt>\/opt\/local\/libexec\/gnubin\/<\/tt>.  I added the following to <tt>~\/.bash_profile<\/tt>:<\/p>\n<blockquote>\n<pre class=\"bash\">export PATH=\"\/opt\/local\/libexec\/gnubin\/:$PATH\"<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>The command-line oddities of Mac OS X&#8217;s BSD heritage drive me insane. I much prefer the behavior of the GNU toolchain, as provided by Ubuntu Linux. To begin, first install MacPorts. MacPorts Installation Variant +with_default_names With several MacPorts packages, the &hellip; <a href=\"https:\/\/www.curlybrace.com\/words\/2009\/03\/command-line-autocompletion-for-os-x\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[270,15],"tags":[266,267,268,269,264,265],"class_list":["post-692","post","type-post","status-publish","format-standard","hentry","category-osx","category-technology","tag-auto-completion","tag-autocompletion","tag-bash","tag-gnu","tag-macports","tag-port"],"_links":{"self":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/comments?post=692"}],"version-history":[{"count":15,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts\/692\/revisions"}],"predecessor-version":[{"id":693,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/posts\/692\/revisions\/693"}],"wp:attachment":[{"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/media?parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/categories?post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.curlybrace.com\/words\/wp-json\/wp\/v2\/tags?post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}