
Monday September 03, 2007
Nautilus scripts to launch diff viewer and view a particular revision
I have hacked two more nautilus scripts.
- cvs_diff_revisions - this script prompts for two revisions of a file and shows diffs them in a diff viewer.
- cvs_view_revision - this script prompts for a revisions of a file and shows it a editor.
Just put the scripts in your
~/gnome2/nautilus-scripts
directory and
> chmod 755 cvs_diff_revisions cvs_view_revision
> nautilus -q
Here are the scripts:
cvs_diff_revisions - this uses the meld diff viewer. You can use any other diff viewer in it's place.
#!/bin/bash
#
# Distributed under the terms of GNU GPL version 2
#
# http://blogs.sun.com/scblog
#
ICONPATH="`dirname $0`/cvs.xpm"
for TARGET in ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}
do
TARGETDIR=`dirname "${TARGET}"`
TARGET=`basename "${TARGET}"`
cd "${TARGETDIR}"
REVISIONA=`zenity --list --radiolist --title="cvs diff - Select Revision A" --text="${TARGETDIR}/${TARGET}" \
--width=500 --height=700 --column "A" --column "Revisions" \`cvs log "${TARGET}" | grep "^revision" | mawk '{ print "FALSE", $2 }'\``
if [ $? -eq 0 ] ; then
if [ ! -z "${REVISIONA}" ] ; then
REVISIONB=`zenity --list --radiolist --title="cvs diff - Select Revision B (A is ${REVISIONA})" \
--text="${TARGETDIR}/${TARGET}" --width=500 --height=700 --column "B" --column "Revisions" \`cvs log "${TARGET}" \
| grep "^revision" | grep -v ${REVISIONA}| mawk '{ print "FALSE", $2 }'\``
if [ $? -eq 0 ] ; then
if [ ! -z "${REVISIONB}" ] ; then
cvs update -r "${REVISIONA}" -p "${TARGET}" > "${TARGETDIR}/${TARGET}.~${REVISIONA}~"
cvs update -r "${REVISIONB}" -p "${TARGET}" > "${TARGETDIR}/${TARGET}.~${REVISIONB}~"
meld "${TARGETDIR}/${TARGET}.~${REVISIONA}~" "${TARGETDIR}/${TARGET}.~${REVISIONB}~"
fi
fi
fi
fi
done
cvs_view_revision
#!/bin/bash
#
# Distributed under the terms of GNU GPL version 2
#
# http://blogs.sun.com/scblog
#
ICONPATH="`dirname $0`/cvs.xpm"
for TARGET in ${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}
do
TARGETDIR=`dirname "${TARGET}"`
TARGET=`basename "${TARGET}"`
cd "${TARGETDIR}"
REVISION=`zenity --list --radiolist --title="cvs view revision" --text="${TARGETDIR}/${TARGET}" \
--width=500 --height=700 --column "" --column "Revisions" \`cvs log "${TARGET}" | grep "^revision" | mawk '{ print "FALSE", $2 }'\``
if [ $? -eq 0 -a ! -z "${REVISION}" ] ; then
cvs update -r "${REVISION}" -p "${TARGET}" > "${TARGETDIR}/${TARGET}.~${REVISION}~"
gedit "${TARGETDIR}/${TARGET}.~${REVISION}~"
fi
done
Also save this cvs icon as ~/gnome2/nautilus-scripts/cvs.xpm.
I think it should be possible to build a set of scripts which more or less emulate TortoiseCVS integration with Windows Explorer.
Posted by sandipchitale
( Sep 03 2007, 07:51:54 PM PDT ) Permalink
Copy Path in Nautilus
I recently switched to Ubuntu. Starting to like it.
Here is my first Ubuntu/Nautilus hack. Put the following python script:
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
import os
# get the clipboard
clipboard = gtk.clipboard_get()
# set the clipboard text data
clipboard.set_text(os.environ['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS'])
# make our data available to other applications
clipboard.store()
in the file:
~/.gnome2/nautilus-scripts/Copy Path
Now launch Nautilus, select any file(s) or folder(s) and invoke pop up menu and select Scripts:Copy Path. The fully qualified path(s) of the file(s) or folder(s) will be copied to the clipboard.
Does anyone know a better way?
Posted by sandipchitale
( Aug 25 2007, 12:15:00 PM PDT ) Permalink