Posts tagged bash

Make “ps -ef” work in a shell on Mac OS X

If you’re used to SunOS or BSD, you’ll be at home with Mac OS X’s “ps -aux” to get a process list from a shell prompt.

If you’ve been using any other recent unix, though, your fingers will want to type ps -ef instead. Rather than hack an alias to wrap ps to make this happen, it turns out there’s an easy way to return to the ps promised lands.

By default on Mac OS X 10.5.2, the shell environment’s COMMAND_MODE is set to legacy. If you set it to unix2003, you’ll get your ps -ef. Just add

export COMMAND_MODE=unix2003
alias zcat='gunzip -c'

to your ~/.bashrc to make it be set automatically.

The alias of zcat to gunzip -c fixes a “feature” in unix2003 mode — it removes gzip support from zcat. If you’re used to using zcat for both compressed .Z files as well as gzipped .gz files, you want the alias line as a workaround.

Ant bash completion on Mac OS X

bash will do tab-completion for ant targets on Debian/Ubuntu boxes out-of-the-box. If you haven’t upgraded lately, you may need to:

sudo apt-get install bash-completion

On Mac OS X, it needs a bit of massaging. First install the macports version of bash-completion and ant:

sudo port install bash-completion apache-ant

Then add this to the end of your ~/.bashrc:

if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
complete -C /opt/local/share/java/apache-ant/bin/complete-ant-cmd.pl ant

See http://marius.scurtescu.com/2005/03/23/ant_bash_completion for Windows instructions.