I am sure some of you have had this issue before if you use more than one platform at home. Personally for me, OS X and iTunes lack some audio features I like so I don't do my audio ripping from my personal CD collection on a Mac. I do it on my windows/Linux box so I can take advantage of some good open source formats like OGG, FLAC, and MP3vbr (though I think the newest release of itunes will support VBR? not sure). [Editor: iTunes has had VBR support for quite a while.] However, I like to have my music collection on my Mac so I can listen to my music when I am working on it, and my laptop is a Macbook Pro.
I am sure a lot of you already know this, and this is nothing new or exciting, but I have used basic Unix commands to copy my music directory from my PC to my Mac using rsync, and have not had it copy over any duplicate albums. For example, I have about 40GB of music ripped to my PC of my own personal collection. When I copy it via SMB over the network, it duplicates about every five albums or so which is annoying. To get around this I simply used rsync instead. Make sure all the proper permissions are in place, so you can mount your share from Windows or Linux box on your mac. Connect to the share and mount it. Once it's mounted, use this very simple command:
You can use this over and over again -- the -u tag should only copy new material from your other computer and not copy what has already been copied. I have been using this method for about a month now, since I rip everything in FLAC then convert it to MP3 and then copy it to my Mac via Terminal. So far no more duplicate albums are being copied using this method.
Also since you can simply drag and drop the file paths directly into Terminal, it makes it even easier. If you were so inclined, you could make a shell script doing this with a cron job so it auto-updates once a week or whatever. This method could be applied from Mac to Mac as well, but if your Macs are networked, you could just share it over AirTunes or what not.
This excellent tip explained how to manage LPR printers using the command line lpadmin printing tool, but there were no instructions on how use printer queues for high-end printers with a RIP -- like those from Xerox and Canon. Typically, these printer queues will contain options such as Print, Hold or Direct. Although it's easiest to use Open Directory to manage your printers and these special settings, if you use ARD or Filewave for Desktop management, you can issue a shell command or shell script to automatically add these special type of printers without end-user disruption.
Simply add your printer's queue to the end of the IP address or URL like the example shell script below, and voila, your users will have all of their special printer configurations added automagically.
#!/bin/sh
#This script installs the left and right Xerox printers in Imaging
lpadmin -p Left242 -L "Left Xerox 242" -E -v lpd://left242.yourdomainorIPaddress.com/PRINT -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/Fiery EX260 Color Server PS.gz"
/System/Library/StartupItems/PrintingServices/PrintingServices restart
Recently, someone asked me how they could use Skim as his TeXShop previewer. That is, he really liked Skim and wanted to be able to use its PDFSync support to bring up a line of TeX source inside TeXShop. So I put together a shell script that mainly consists of the following:
If you save this script as texshop in your PATH (e.g, as /usr/local/bin/texshop) and chmod it 0755 (e.g., chmod 0755 /usr/local/bin/texshop), then you can go into the Skim LaTeX preferences and set the Preset to Custom, with the Command set to texshop, and the Arguments set to "%file" %line. I hope some other people find this useful
After reading a lot of things about the issue of non-saving history files after session closing in tcsh (my favourite shell, especially for its completion flexibility), I founded that putting these lines...
set history = 2000 # History remembered is 2000
set savehist = (2000 merge) # Save and merge with existing saved
set histfile = ~/.tcsh_history
...in .tcshrc and this line...
history -S
...in .logout solved the problem. Now history is not only preserved between Terminal sessions, but also merged (considering command dates). Also, it is not necessary to issue an exit command, but with a normal window close, the current history is merged.
[robg adds:This older hint covered savehist, but it seems you still had to use exit to get everything to work. The above solution should also work if you simply close a Terminal window.]
I have read all the hints about command line calculators, and I've tried just about all of them, including:
Python
awk
bc
Unfortunately, none of these options had built-in functions like sin() or cos(), or constants like pi. For Python, in order to include the math library you have to type from math import *. But then to get it to do the things you want (like adjusting precision), you have to be familiar with Python and/or you have to read documentation on the Python math library. The problem with bc is that when you type bc -l you only get six built-in functions, such as s(), c(), a(), which are sine, cosine, and arctangent respectively. You don't get any built-in constants.
There's a better way, but it requires a small download of a program called wcalc. If you have Fink installed, you can just type fink install wcalc (or get the pre-compiled version via sudo apt-get install wcalc. After you've installed wcalc, on the command-line in Terminal, type wcalc and you're set to go. The program provides you with a prompt and tells you "Enter an expression to evaluate, q to quit, or ? for help." It's pretty self-explanatory.
[robg adds: The Fink version of wcalc is 1.7. However, on the home page I linked above, you can download version 2.2.2 for Mac OS X, which also includes a GUI version.]
Showing the latest job in each window title is my preferred way to tell multiple Terminals apart. Unfortunately the GUI method is rather useless (File » Set Title... » Active Process Name will make most windows say bash), and this old hint only covered tcsh. To update it, here is (in a nutshell) the command to issue, or to put in the appropriate startup file:
While the how-to cited in the old hint did contain the zsh and tcsh methods, and while in retrospect the ksh trap '...' DEBUG method had been working since long before, the idea of using it for the present purpose seems newer and due to Paul Jarc, who first mentioned it shortly after bash switched to the ksh93 standard of running '...'before (rather than after) each interactive command. (Prior to that, the effect was reputedly impossible to obtain without recompiling bash.)
Lately zsh (≥ 4.3.3) also rescheduled the trap, so recent versions also support Jarc's method -- provided you preface it with set -o debugbeforecmd.
If you know the name of a running command line process, but don't know the precise command line with which it was invoked, you can run a command such as this one to return the complete command:
After finally getting tired of remembering to "Empty Trash" at regular intervals, I decided to write a script (36KB download; source code on macosxhints) that automatically cleans files out of the trash after they've been there for seven days. It will even use sudo to clean out things that I don't have permission to erase -- if that option is available. There are many options to choose from, just use --help to see them all.
This script is designed to be very efficient to run, so I run it hourly. There is not (yet) any provision for maintaining the Trash at a particular size. I recommend adding a line to your cron file like this:
@hourly python /your/path/to/dirscan.py
This will clean things out after a week, and checks each hour for new items to remove. It pays attention only to top-level entries within .Trash, so any directories you put in the trash will be deleted automatically.
[robg adds: The code download link is from the author's site, and will be the best place to grab the latest version of the script. I mirrored the source as of today on macosxhints.com, just in case the parent site goes away at some point. Note that I haven't tested this one. Finally, for those interested in a size-limited trash can, this hint and the associated comments offer a few solutions.]
After searching the forums and trying various things, I still couldn't find a quick, reliable, free method of burning a VIDEO_TS folder to a pure UDF DVD, so that it would play in regular DVD players, as well trigger DVD Player to start up automatically. Anyway, as often is the case, Terminal had the answers. Just type in this command and change the paths to suit:
Make sure that /path/to/VIDEO_TS/parent/folder is the path to the folder containing the VIDEO_TS folder, not the VIDEO_TS folder itself. Once the .iso file has been created, drag this to Disk Utility and hit the Burn button.
The first thing I do when I start to work is launch a slew of Terminal windows to log into various servers and/or interact with repositories and local files. I quickly found that is was helpful to color code them so, for instance, if I want to grab the one logged into server X, I can see them in Exposé and be able to choose the window I want by remembering its background color -- even without being able to read the characters. So I wrote a little AppleScript to automate the process; it can likely be improved as it's the first AppleScript I've written:
set RGBGreen to {0, 10000, 0} as RGB color
set RGBRed to {10000, 0, 0} as RGB color
set RGBBlue to {0, 0, 10000} as RGB color
set RGBBlack to {0, 0, 0} as RGB color
set RGBWhite to {65535, 65535, 65535} as RGB color
set RGBcolors to {RGBGreen, RGBRed, RGBBlue, RGBBlack}
repeat with curColor in RGBcolors
tell application "Terminal"
activate
with timeout of 1800 seconds
do script with command "pwd"
tell window 1
set background color to curColor
set cursor color to RGBGreen
if curColor = {65535, 65535, 65535} then
set normal text color to RGBGreen
else
set normal text color to RGBWhite
end if
set bold text color to "red"
set title displays shell path to true
set title displays window size to true
set title displays device name to true
set title displays file name to true
set number of columns to 120
set number of rows to 40
end tell
end timeout
end tell
end repeat
Obviously colors, the number of windows and the like are easily tweakable.