Posts tagged as "mac":
The Lesson About /usr
Lately I have taken it upon myself to upgrade certain unix friendly applications which ship by default with Mac OS X Leopard. I can not say for sure what started this but I’m fairly certain it began with MacFuse and and my desire to find various things which would allow me to make use of this awesome bit of technology. The first one I found was sshfs which is available as from the MacFuse developers. Soon after I read something about the mystically difficult to find ftpfs. For reasons I can no longer recall I decided I simply had to find and install it. The one I found was curlftpfs and when I attempted to compile it I quickly discovered my version of curl was not up to snuff.
Having been shamed once by an installer I quickly reached out in search of the latest version of curl’s source. After all I’ve done the configure; make; make install routine plenty of times before. Sadly it took me far too long to realized the vast majority of time I’ve done the configure; make; make install routine it was to install new software not upgrade existing packages. So I went through the process the first time and couldn’t get curlftpfs to compile still; curl had not been compiled to the correct location because the old version of curl was still being found in the path. Running blithely ahead I recompiled with the ‘correct’ prefix of /usr. Now this install location should have been my second clue signifying I should stop what I was doing. Instead I moved right along compiling and installing into the /usr directories. I finished compile attempt number two for curlftpfs having learned it had not been compiled with some necessary option enabled and so it was time to compile curl again this time with the option enabled. Of course here the configure fails because I am missing the necessary libraries.
Naturally forging ahead I go and get the missing libraries compile and install them and try curl again. I have forgotten the reason but I know I was doomed for a couple more failures before I attempted to do what I should have done in the first place which is use my already installed MacPorts and just upgrade. Which is what I eventually try. However, it would appear the port command provided by MacPorts also relies on curl so this is a total bust. At this point I’ve forgotten all about getting curlftpfs to work and just want curl and port working again. By this time my frustration must have been palpable because I have no recollection of what I did to get those two things correctly compiled and running again.
The lesson I have learned from this is pretty simple. Don’t mess with the /usr directory without a backup/restore plan.
Displaying Git Branch in the Command Line
I was hunting around looking for information about port from svn to git and getting git-svn to compile on OS X a little while back when I ran across Maddox’s explanation of branch name in command line. At the time I thought ‘Awesome!’ but I was on a mission so into del.icio.us it went to await later discover.
A couple of days ago I found the post again in my bookmarks and proceeded to spruce up my command line with the knowledge in Maddox’s post and in MacTip’s Customize Prompt on OS X article. The long and short of it is that the colors in my command prompt bother me so I cut them out of Maddox’s function and ended up with the following to lead off my ~/.bash_login.
Prompt Setup
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^]/d' -e 's/ (.*)/[\1]/'
}
function gitPrompt {
PS1="\h:\W\$(parse_git_branch) \u\$ "
PS2='> '
PS4='+ '
}
gitPrompt
I have to say I’m quite please with the new addition to my command line!
How-To: Adding Foldings to Javascript Files in MacVim
Having used TextMate for a while I have grown quite accustomed to being able to fold sections of code, particularly function declarations, so I can glance through the file to see what functions and variables I have defined. However, I recently made a totally nerd bragging rights based decision to test out MacVim. Well it wasn’t all bragging rights, being able to navigate a file without having to move my fingers from ‘home base’ would be a big plus.
The project I’m currently working on though has a couple of really large javascript files and navigating them quickly in MacVim without the foldings was something I found to be quite difficult so I started looking at the Vim help files and found the ability to create folds. Due to a disciplined use of tabs to indent code blocks :set foldmethod=indent worked fairly well but eventually it started to bug me because the of the fold was actually the first line of the content which meant the folds looked something like functionName: function() {
There had to be a better way. I realized what I wanted to do was create a fold on the line with the function declaration down to the line with the ending brace. I could not find an easy command to do this so I created a simple javascript filetype plugin (addfoldings vim plugin).
+ - - if (test) {
},
In order to get this to work I had to add filetype plugin on to my .vimrc file and I had to create the ~/.vim/ftplugin/javascript directory and drop the addfoldings.vim file into it. By default the foldings are all open but they have been created.
Update: Things are of course never as easy as they seem. The above works fine as long as you don’t add lines to the file you’re working on which is of course absurd, additionally it won’t update the foldings as you go which sort of limits the usefulness. Hopefully I’ll be able to update this to be more useful.