Monday, December 10, 2007

Copy Firefox bookmarks

Firefox provides an official way to export and import hence copy bookmarks from one machine to other. Now suppose your bookmarks got overwritten accidentally so what you do.

To save yourself, firefox backs up your bookmarks at regular intervals. Although it does not provide a GUI to restore old bookmarks but they are saved.


To do so: go to c:\Documents and Settings\your_username\Application Data\Mozilla\Firefox\Profiles\your_profile. There you will see a bookmarks.html file which is you current set of bookmarks. You will also see a "bookmarkbackups" folder wherein you have your backups. To restore, just copy the bookmark backup to the profile folder and restart your firefox and you are done.

Thursday, December 6, 2007

Setting $DISPLAY in bash and csh

For Bash, open the .bashrc file in you home directory in you favorite editor vi and append the following script at the end of it:

#
# Set the DISPLAY
#
if [ x"$DISPLAY" = x ]
then
TTYPORT=`tty`
if [ "$TTYPORT" = "/dev/console" ]
then
DISPLAY="localhost:0"
elif [ "$REMOTEHOST" = "" ]
then
TTYNAME=`echo $TTYPORT | cut -c6-`
REMOTEHOST=`who|grep "$TTYNAME"|awk '{print $5}'|sed 's/(//'|sed 's/)//'`
DISPLAY="${REMOTEHOST}:0"
else
DISPLAY="${REMOTEHOST}:0"
fi
fi


For Csh, open the .cshrc file in you home directory in you favorite editor vi and append the following script at the end of it:

#
# Set DISPLAY
#
if ( ! $?DISPLAY ) then
set TTYPORT=`tty`
if ( $TTYPORT == /dev/console ) then
setenv DISPLAY "localhost:0"
else if ( $?REMOTEHOST ) then
setenv DISPLAY "${REMOTEHOST}:0"
else
set TTYNAME=`echo $TTYPORT |cut -c6-`
set REMOTEHOST=`who|grep "$TTYNAME"|awk '{print $6}'|sed 's/(//'
|sed 's/)//'`
setenv DISPLAY "${REMOTEHOST}:0"
endif
endif

Note: The csh script is tested on Sun Solaris and the bash script is tested on Ubuntu and Fedora so is expected to work on other flavors of linux too. If you have a different *Nix system then check the output of 'who' and configure your awk accordingly.