Tuesday, May 25, 2010

Linuxization of Mac OS

So I've been working in Mac OS as an experiment for a bit over a week. I'm VERY used to working in fedora as I've been doing that for about 5 years. The following tweaks are the result of hating some of the Mac OS defaults.

1. Using a black background in my xterms.
First of all, the lack of mouse passthrough for vim in Terminal.app means it's a non-starter for me. Here's what my ~/.Xresources file looks like:
XTerm*background: black
XTerm*foreground: white
XTerm*scrollBar: false
XTerm*utf8: 1

xterm*saveLines: 10000
xterm*jumpScroll: true
XTerm*scrollBar: false

xterm*visualBell: true
xterm*loginShell: true
Some of those options are on by default but I included them for posterity.

2. Environment fixes for black terminals and XTerm titles
The defaults really stink for a dark background terminal and the default static title of 'xterm' is not terribly useful. Here are the interesting parts of my .profile and .bashrc.

.profile:
. ~/.bashrc

.bashrc:
#Mac OS colors
alias ls="ls -G"
export LSCOLORS='DxGxfxfxcxDxDxhbhDecec'

# Xterm Titles in mac os
# are we an interactive shell?
if [ "$PS1" ]; then
 case $TERM in
  xterm*)
   if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
   PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
   else
   PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
   fi
   ;;
  screen)
   if [ -e /etc/sysconfig/bash-prompt-screen ]; then
   PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
   else
   PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
   fi
   ;;
  *)
   [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
   ;;
 esac
fi

I also highly recommend MacVim (http://code.google.com/p/macvim/). I've got the latest snapshot installed and it works incredibly well. Use 'mvim' to open files from xterm.

I've got a few other personalizations that are just personal preference that I'll have to toss on here later.

2 comments:

Ryan said...

I'm attempting to keep my .bashrc portable to linux hence the /etc/sysconfig paths in there.

Ryan said...

For the record, I'm still full timing in mac os and I don't even use xterm anymore. MacVim (and ITerm2 for a terminal when needed) for the win!