Sunday, August 9, 2009

Symlinks and Bash

A symlink is a file that contains a reference to another file or folder. A directory listing using a link must end with a slash to give the listing otherwise, only the link itself will be displayed.
ln -s [original-file] [link-name]

On MacOS and some linux distributions the link will be updated to follow the target if the target is moved.

~/.bashrc is run at login
~/.bash_profile is run when bringing up interactive prompt
~/.bash_logout is run when the login shell exits

Generally you will want to have one copy of your login preferences in .bashrc and load the .bashrc file from .bash_profile.

To reload the shell:
source ~/.bashrc

pbcopy is a script that allows the clipboard to be used from the command shell.
cat some-file | pbcopy

open and open -a will open a file or location; the -a flag allows you to specify an application.
open -a Firefox http://localhost:8080

References:
Bash Manual
Bash Manual - Navigating the Command Line