As great and as easy as the OS X user interface is, sometimes it is quicker or necessary to jump into the deep dark bowels of your system on the command line. OS X ships with the very competent Terminal.app that allows easy access to this, but the default view into your machine is dull and boring. It doesn’t have to be. Here are a few tips to style things up a bit.
Visor has been mentioned in the past here at TheAppleBlog, and for good reason. It works as an add-on to Terminal to give you a ‘quake-style’ drop down HUD interface. You press the hotkey and a terminal drops down from out of nowhere in a fast, convenient, out-of-the-way manner — complete with tab support.
If you search for Visor on the web, you’ll most likely end up at its Google Code page, where it seems that the most up-to-date version is 1.5a1 from November 2007. Fear not, for Visor is still being developed and the latest version is actually 1.81, released on March 5 of this year.
To download it you need to go its GitHub page and click the link to the pre-compiled binary. Follow the instructions to install it. 1.81 adds more options to play with, but most importantly for me, is that it enables full custom key-stroke support — so any keys defined in Terminal are usable in Visor.
Hiding Visor’s Terminal
Because Visor hooks into the Terminal application, it needs to be running and cluttering up your dock and command-tab icons all the time. Fortunately, there is a nice hack that will get Visor running ‘invisibly’ without any sign of Terminal.app running. This makes for a cleaner desktop experience while still leaving a terminal only one keystroke away.
To do this you need a plist editor — if you have the OS X Developer Tools installed you already have the Property List Editor app. If not you can download PlistEditPro which has a free trial period and will do the trick for you. The following steps assume you already have Visor installed and working.
- With Finder, show the package contents of ~/Library/Application Support/SIMBL/Plugins/Visor.bundle (right click to access this option) and load the file Contents/Info.plist in your plist editor. From the root node, expand
Item 1and change
- Make a copy of Terminal.app that is in /Applications/Utilities and call this copy Terminal_Visor.app
- With Finder, show the package contents of the new Terminal_Visor.app and open its Contents/Info.plist file in your plist editor. From the root node, change
- Run Terminal_Visor and make sure Visor works properly. Configure all Terminal preferences and settings to your liking. Right click on the Terminal_Visor dock icon and select Open At Login to make it starts up automatically.
- With Finder, show the package contents of /Applications/Utilities/Terminal_Visor.app and open its Contents/Info.plist file in your plist editor. Add a new
Numberentry at the bottom called
LSUIElementand set its value to
1. (This entry can also be known by its descriptive name of “Application is agent (UIElement)”). Relaunch Terminal_Visor and there will be no sign that its running except when you press your Visor hotkey.
Now you have less clutter with the same power. To make Terminal_Visor visible again (to change preferences) change the
LSUIElement value back to
0 in its Info.plist. To quit Terminal_Visor when it is running, you can toggle the visor terminal with a hot-key and then press Command + Q.
Colored Directory Listings
By default when you type the
ls command you get a dull black and white listing. This is very old school and in this day and age we have the technological marvel of colored directory listings. This shows different file types in different colors, allowing you to be quickly informed with a simple glance. To enable support for this, all you need to do is create (or open it if it already exists) a file called ~.bash_profile in a text editor (note the dot before the name — this is a hidden file). Add the following lines:
Start a new terminal session and, lo and behold, you have a colored directory listing. You can customize what colors are used by modifying the LSCOLORS variable, which defines what type of file is shown as a particular color. A nifty tool to help you come up with the appropriate value for this is the LSCOLORS Generator.
A More Useful Command Prompt
When you start a terminal session you are normally greeted with a white prompt that looks something like
BedPro:~ Bed$, where “BedPro” is your machine name, “~” is the currently directory you’re in and “Bed” is your user name. This can be changed to almost anything you like and it can be helpful to do so to quickly differentiate the prompt from command output, and to show more information such as the fully qualified current directory path (like “UsersBedDocuments” rather than just “Documents”). My prompt (see screenshot above) is separated from the last command output by a blank line, lists who I am on what machine, and the full directory path. Then I have a blank line to type at.
You can configure a custom prompt by creating (or editing, if it already exists) the text file ~/.bash_profile and adding a line like mine:
export PS1="n[e[1;40;30m]u@h:wn> [e[0m]"
u@h:w gives me
username@host:fulldirectory while the
n is a newline. The other codes are the color definitions.
Colors can be rendered in various ways by Terminal.app, so in addition to setting the
ls and prompt colors in your .bash_profile, you may also need to tweak Terminal’s settings to achieve the results you like. These can be found in the Settings dialog. In particular I like to uncheck using bold fonts, and check using bright colors instead.
Any other tips?
Are there any other Terminal add-ons you use that are indispensable? Have any other tips for a more stylish experience? Let us know in the comments.