Terminal

Switching: Linux App Equivalents

I have been in the process of planning out switching to Linux in 2010 for my main development computer (a laptop), as well as for various web and database servers I am responsible for at work.

I've been making good use of Sun's awesome (and free) VirtualBox program, which allows me to create any number of virtual computers to experiment on. I've had a couple of CLI-only server versions running (Debian and Ubuntu), as well as what amounts to a desktop system for the last three Ubuntu releases: 8.10, 9.04, and the just-issued 9.10.

tron.jpg

My User has information that could... that could make this a free system again! No, really! You'd have programs lined up just to use this place, and no MCP looking over your shoulder.

I'll cover the whys and wherefores of switching in the future. For now, suffice to say that the ever-increasing commercialization of Mac OS X, with accompanying restrictions, has been grating on me for some time now. I am also attracted to the notion of software freedom (having been a huge fan of the original Tron movie ;) and of course the cost savings can be dramatic. And since I work primarily in education, I think we would be neglecting our duty by not exploring the open-source world.

dumont.jpg

All that is visible must grow beyond itself, and extend into the realm of the invisible.

One of the first and ongoing steps is compiling a list of application equivalents to programs I am need of.

Still looking:

  • Time Machine (backup) -> roll-my-own or manual?
  • Bluetooth File Exchange -> built into Gnome?

Stuff that exists in both places:

If you're looking into switching as well, or just are looking for new apps to try out whatever your platform, check out AlternativeTo, which provides alternatives for Linux, Mac, and Windows programs.

Note: Written before the current cold whacked me in the head and upper respiratory tract. Bits are incomplete. Suggestions are welcome.

End of line.

Where are Mac OS X Spaces preferences stored?

While the options for Mac OS X's Spaces are set in System Preferences, you won't find them stored in the ~/Library/Preferences/com.apple.systempreferences.plist file.

Spaces are part of the Dock subsystem (like the Dashboard), so that's where you need to look: ~/Library/Preferences/com.apple.dock.plist

Unfortunately, those Apple .plist files aren't just text any more, so you'll need to open it the Property List Editor found in /Applications/Utilities although you can just use the Terminal like this:

open ~/Library/Preferences/com.apple.dock.plist

to bring it up automatically. You'll find Spaces referred to as "workspaces":

  • workspaces
  • workspaces-app-bindings
  • workspaces-cols
  • workspaces-rows

How do I reset Spaces preferences?

To reset a particular item, delete the appropriate row, then save and close the .plist file. So, for example, if you wanted to clear out all the apps you have assigned to various Spaces, delete the "workspaces-app-bindings" row.

Once you're done deleting stuff, you could log out and back in to reset the Dock process and thus Spaces, or you can geek out on the trusty Terminal again. First, find the process number of the Dock:

ps ax | grep dock

You'll see something like this:

134 ?? S 4:44.40 /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock

That first number, in this case "134," is the process ID number for the Dock. Use this command to "kill" and relaunch it:

kill -HUP 134

Enjoy!

How to edit remote files with local vim

So I finally got around to looking up how to edit remote files with local vim[1]. You do need to have an ssh public/private key set up[2] for the server in question.

On the command line, use the format:

vim scp://username@example.com//path/to/document

Note the double // after the domain name -- this gives you an absolute path on the remote box.

This technique works with the GUI gvim or MacVim applications too by using the :e command inside the program. Open up a new window and type

:e scp://lisa@example.com//www/docs/bleeding_gums.html

Bonus Tip #1

If your local username is the same as your remote username, you can eliminate it in your command. So, for example, if you were username "frink" in both places, you could use something like

vim scp://example.com//Users/frink/Documents/frogexaggerator.py

to access and edit your Frog Exaggerator controller script in your remote Documents folder.

Bonus Tip #2

Can't remember the name of your remote file? Don't worry -- open a directory instead!

:e scp://example.net//Library/WebServer/Documents

You'll see a list of the directory's contents. Move the cursor to your desired file (or subdirectory) and hit return to open it. Naturally, this also works on local items.

Give me more!

You can read more in depth info at the appropriately titled Vim Tips Wiki article "Editing remote files via scp in vim".


[1] Or gvim, MacVim, etc.

[2] Actually, you can use several different methods in addition to scp -- ftp, http, etc. -- but I had the automatic ssh login in place already.

A command line ebook reader

I was casting around for a replacement for the excellent Tofu screen text reader for Mac, due to some encoding issues. Always wont to explore the command-line options, I turned first to the ubiquitous less pager, available on pretty much every unix-alike system out there.

The only real drawback to less is its apparent inability to wrap long lines at spaces rather than chopping words in the middle and sans hyphenation. This isn't a problem on hard-return files like a Project Gutenberg ebook, but makes for difficult reading otherwise. (The opposite is the case for Tofu, which requires a bit of manual column widening to compensate for the hard returns.)

Doing a bit of poking around, I re-discovered the also-ubiquitous fmt command, which does word wrapping to a fare-thee-well, though doesn't do paging.

Combining the two commands gives the best of both in classic Unix fashion:

fmt 1911EthanFrome.txt | less

You can also use options to enhance the experience. less -m will give you a prompt showing how far along you are in the file; see man less for others.

The pager recognizes vim movement keys, which I love. Plus you can hit the v key at any time to drop into vim, edit the file, and then return to less. Spiffy.

Of course, you could just use vim (or your favorite text editor), but I like the simplicity without the overhead. Unlike other options, less doesn't read the entire file into memory before displaying it, a definite advantage on big documents.

Another Tip: If you're in a Mac Terminal window, right click on a word or phrase to search for it in Google or Dictionary.

Bonus tangential tip: if you don't care about downloading the text files but want to stick to reading Project Gutenberg files in the terminal, why not use lynx or ELinks?

screenshot of terminal window showing lynx web browser viewing the Edith Wharton novel Ethan Frome on Project Gutenberg

Command line tea timer for Mac

Cuppa is a spiffy tea timer program for Mac (if only for its sound effects ;), itself inspired by The Tea Cooker from Linux. However, there's an easy way to create a de facto tea timer, or run any kind of countdown, via the Terminal.

The sleep command allows you to run other commands or programs with a delay. So, for example, you could enter,

sleep 20; ps

which will pause for 20 seconds, then run ps to show your active tasks.

To keep you from having to stare at the Terminal window waiting for your tea countdown to finish, we'll make use of the say command, which taps into your Mac's built-in Text-to-Speech ability. (See System Preferences > Speech.)

So, assuming you want your Earl Grey to steep for four minutes, you could use something like this:

sleep 240; say "Your Tea, Earl Grey, Hot, has completed brewing."

Or for your Green Tea:

sleep 60; say "Green Tea processing complete."

Enjoy!

UPDATE 2009-10-23:

Following up on this, you can get the best of both worlds by using the popular Growl notification system -- specifically, the CLI growlnotify program, found on the Growl install disk image (see description on their Extras page for more info). Then you can do something along the lines of,

sleep 120; growlnotify --message "Dude, your most excellent tea is ready."

See man growlnotify for finer control.

Lynx package for Mac OS X

Via osxgnu.org, a Universal Terminal and Finder-clickable Lynx package (self-contained), currently at version 2.8.6u.

links for 2007-10-24

  • Terminal Productivity Tips
    "...the most useful hints for working on the command line in the context of OS X server. It's probably aimed at people who work with Terminal every day...but have never had the time to look around for tips to boost their productivity."
Syndicate content