-Tarrant
The traditional method of package management for Vim is complex and painful. Currently to install a package you download a zip or file and place it into one of many directories under .vim. If the zip contains more than one file you have to ensure that each is placed into the proper folder.
Now let’s say you want to delete or upgrade a package. Are you sure you got all the files?
Pathogen is an add-on for Vim that that greatly simplifies this process. Instead of merging the contents of the zip into one .vim folder, pathogen will load the files from .vim/bundle/<plugin-name>/.
For example instead of putting python.vim (from the python-vim plugin) into .vim/syntax/ directory, pathogen will allow you to load python.vim from .vim/bundle/python-vim/syntax/python.vim.
Now with easy loading we just need easy downloading and upgrading of plugins. Git to the rescue.
Almost all Vim plugins are hosted on github at this point. Either under the author’s repository or under the vim-scripts user which mirrors the official Vim Scripts site.
Installing an addon can be preformed by simply running cd ~/.vim/bundle/ &&
git clone <repository>. Upgrading can either be done in batch with a bash or ruby script or one by one by running cd ~/.vim/bundle/<plugin> && git pull.
Most guides I’ve found online about reloading clojure code talk about re-compiling code only. This is nice but I want to be able to make small changes and process them quickly in the repl.
Apparently this is not too difficult if you know what to do.
(ns test.core
(:require [compojure.route :as route]
[compojure.handler :as handler]))
(defroutes main-routes
;; Fill in routes here
)
(def app
(handler/site #'main-routes))
;; Dev Server Functions
(defonce server (run-jetty (var app) {:port 8080 :join? false}))
(defn start-server []
(.start server))
(defn stop-server []
(.stop server))
(defn reload-server []
(do (stop-server)
(start-server)))
The magic bit seems to be the extra level of indirection from the (handler/site #'main-routes). The #'main-routes causes handler/site to refer to the ‘var’ that the main-routes symbol points to instead of the value. This means that when updated they both still point to the same data.
Running a server in parallels is a bit annoying since it insists upon you having the console running at all times.
There are a few ways around this. The first is to use the iPhone app to start your virtual machine as seen at The NetWorker Blog.
Another approach which can be preformed without external tools is to use prlctl(8) a command line utility for managing parallels.
The first thing to do is make sure you are not running parallels desktop. If it is running then the console will appear as it always does.
Next run the command prlctl list -a which will display all of your virtual machines and their current state.
Finally run the command prlctl start VM_NAME replacing VM_NAME with the virtual machine name you got from the previous command.
Congrats you now have a headless server running. ssh into it and work as normal.
Sadly when you next open the Parallels Desktop utility the server’s console will display and you will have restart the process to make it go away.
Accidentally run apt-get install sendmail on the wrong server. Well say good bye to your mail server. Ubuntu will remove your existing mta, and randomly delete half of your config files.
http://superuser.com/questions/202821/terminal-not-running-shell-bash/239455#239455
I recently came across Top.app which shows how to build a .app bundle for a terminal command. Specifically top(1). The blog post in question is a bit out of date being written for what seems to be OS X 10.4
We need a working copy of Terminal.app in order to get started. We can place this either in ~/Applications or /Applications.
# Replace NAME with the name you want.
# To make it system wide use:
cp -r /Applications/Utilities/Terminal.app /Applications/NAME.app
# To make it user specific:
cp -r /Applications/Utilities/Terminal.app ~/Applications/NAME.app
Woot! We are 90% of the way there. If you open NAME.app you now have a separate icon on your dock. As far as Dock, expose, or command+tab are concerned this is a separate program.
Change the icon however you normally would for your mac apps.
![]()
If you don’t use an external management tool then the easiest way is to find the Application in Finder and press the “command+i” (or right click and select Get Info). Perform the same on the application who’s icon you wish to steal.
Now click on the icon you wish to steal in the top left hand corner and copy (‘command+c’). Do the same to the icon you wish to replace except paste (‘command+v’).
Like magic you now have a non-terminal icon.
In your favorite text editor openContents/Resources/English.lproj/InfoPlist.strings
for the new application. Change any occurrence of Terminal with NAME on the right hand side of the equals.
# Change:
CFBundleName = "Terminal";
CFBundleDisplayName = "Terminal";
"Terminal session" = "Terminal session";
"Terminal settings" = "Terminal settings";
"Terminal shell script" = "Terminal shell script";
# Into:
CFBundleName = "Top";
CFBundleDisplayName = "Top";
"Terminal session" = "Top session";
"Terminal settings" = "Top settings";
"Terminal shell script" = "Top shell script";
Open the Info.plist from the Contents folder inside of your bundle. Double clicking on the file should open it in the Property List Editor if you have Xcode installed. Change the Bundle Identifier value to something of your own.
If you don’t have Xcode installed, open the file in your favorite text editor.
Find the lines below:
<key>CFBundleIdentifier</key>
<string>com.apple.terminal</string>
and change the string value to something unique:
<key>CFBundleIdentifier</key>
<string>com.daemonomicon.NAME</string>
Run your new application and enter the properties. Change the Shells open with: option to Command and enter the complete path for the command you want. If you don’t know the complete path use the which(1) command to figure it out.
If you want, you can change the title in the window bar to anything you like under the ‘Settings->Window’ tab.
Congratulations you now have a application specific to your command line utility. This can be super useful when you use applications like Mutt, or IRSSI. This provides you with greater flexibility in managing the application independent of your other Terminals.
For example you can bind your Mutt window to appear on all desktops in Spaces, or quickly switch to your IRSSI window with a ‘command+tab’.
It should be made abundantly clear 99% of this work for this trick/tool is from Ryan Tomayko. All I’ve done is rewrite it removing some cruft that is no longer need in OS 10.6
I spent a while earlier today trying to process return codes from system. Turns out that system does not return an integer containing the return code but returns a ‘bit-or’ structure containing several bits of data, part of that being the return code.
In order to access the return code from a system you will need to do the following:
int retcode;
retcode = system("cat /proc/cpuinfo");
retcode = WEXITSTATUS(retcode);
WEXITSTATUS is a macro used to extract the info from ‘bit-or’ structure that wait passes back. There is additional info contained in this structure. More detail can be found in wait(2).