Coloring Darwin (OS X) Shell with GNU tools
From the look-ma-i-display-colors-too dept. (7512) (0) by Luis
Ever wanted to get Terminal.app in MacOS X to
display your files in color? Well, read on this article and
you should find a easy way of how to do it. I included
the binaries as well as the configuration files to make it
happen. Just to make some people's life easier. But
you can always download the files from GNU
(ftp.gnu.org/gnu) and go about configuring and creating
the necessary scripts/config files...
k, for the inpatient, I'm going to start straight to the point:
First, this is what you need, which as I said you can either get it from GNU (ftp.gnu.org/gnu) and use Darwin's GCC (Apple developing tools) or just click on the links I provided and download them from here. If you get the binaries I provided, then you don't need to get the sources for Bash2 or Fileutils. That's the 'lazy' way. I will later explain the 'advanced' way, of course, in advanced terminology :-)
1. fileutils ( gnu )
2. bash 2 ( gnu )
3. configuration files ( latinomixed.com )
and to make your life easier so that you don't have to compile anything:
4. binaries ( latinomixed.com )
And that's basically it. Now, depending on what procedure you chose to do, the lazy one, or the advanced one, this is how to go about:
Lazy way:
1. Get the configuration files and the binaries provided
2. Move the configuration files according to the structure they have in the tar.gz file. Example:
Assuming you downloaded osX_darwin_config.tar.gz and osX_darwin_binary.tar.gz to $HOME/Desktop (where $HOME means /Users/myuser) and that you want to put all the sources in /usr/src/ then open a terminal and type the following:
sudo mkdir /usr/src
cd /usr/src
sudo tar -xzvf ~/Desktop/osX_darwin_config.tar.gz
sudo tar -xzvf ~/Desktop/osX_darwin_binary.tar.gz
sudo mv etc/* /etc/
sudo mv home/user/bash_profile ~/.bash_profile
sudo mv home/user/bashrc ~/.bashrc
sudo mv usr/bin/* /usr/bin
sudo mv usr/info/* /usr/info
sudo mv usr/local/bin/* /usr/local/bin
sudo mv usr/man/man1/* /usr/man/man1
sudo mv usr/man/man3/* /usr/man/man3
now make necessary symlinks
sudo rm /bin/ls; ln -s /usr/local/bin/ls /bin/ls
sudo ln -s /usr/bin/bash /bin/bash
and if you later decide to compile your own version of bash, you can use the config.status file that I used:
mv usr/src/bash-2.05/config.status /usr/src
or any where else you decide to put it; where your bash source files are
HINT: you could also make your own script and do all this commands at one shot! Follow this:
sudo touch /usr/src/myInstall_script.sh
sudo vi /usr/src/myInstall_script.sh
(copy and paste the text from above)
in vi type: ":wq" (colon 'wq') (write and quit)
sudo chmod 0750 /usr/src/myInstall_script.sh
sudo /usr/src/myInstall_script.sh
Even though it's a nice expirience to just type those commands :-)
3. Go to Terminal.app preferences (Terminal:preferences:shell) and change your shell to /bin/bash
Advanced:
If you are reading this is because you know the shell and you are familiar with compiling with GCC and moving around in the UNIX filesystem. Assuming that, let's rock!
1. Get the source files for bash-2.05.tar.gz and for fileutils-4.1.tar.gz (either from GNU or here for bash and here for fileutils; these files are exactly the same ones you would get from GNU)
2. Assuming it's in ~/Desktop do the following:
for this to work, root account must be enable,
if not just do 'sudo' for all commands that need a super user.
for you to activate 'root' you can do it from NetInfo.
That's well documented, and is out of the scope of this document.
But, it's easy to do
su
mkdir /usr/src
cd /usr/src
tar -xzvf ~/Desktop/bash-2.05.tar.gz
tar -xzvf ~/Desktop/fileutils-4.1.tar.gz
cd bash-2.05
./configure --prefix=/usr --host=powerpc-apple-osx
gnumake
gnumake install
ln -s /usr/bin/bash /bin/bash
cd /usr/src/fileutils-4.1/ # or just cd ../fileutils-4.1/
./configure --host=powerpc-apple-osx
gnumake
gnumake install
rm /bin/ls
ln -s /usr/local/bin/ls /bin/ls
now the config files for bash
cd /usr/src/
tar -xzvf ~/Desktop/osX_darwin_config.tar.gz
sudo mv etc/* /etc/
sudo mv home/user/bash_profile ~/.bash_profile
sudo mv home/user/bashrc ~/.bashrc
And that's it! All you have to do is change your shell in Terminal.app (Terminal:preferences:shell). Also, you might want to change your default shell in case you log in remotely. You can either use NetInfo (I don't like NetInfo at all) or you can type: chsh username. And edit the line 'Shell: /bin/tcsh' to 'Shell: /bin/bash'. Period
I hope that i cover all commands needed and that this procedure works as flawlessly as possible. Now, if you do need my help, or if these procedures need clarification/modification, please email me at lems1@latinimoxed.com