Tuesday, August 7, 2007

Using grep with find

This is how you can use find to first restrict to all .r files and then use grep on them

find . -name "*.r" -exec grep "rho" '{}' \; -print

Using grep with find

This is how you can use find to first restrict to all .r files and then use grep on them


find . -name "*.r" -exec grep "rho" '{}' \; -print

Friday, June 8, 2007

Attach files to thunderbird directly from commandline

Install the script ( e.g attach.sh )


#! /bin/bash
#
# Script created by ASID
# Modified by sura
# Attach files to thunderbird

temp=""
count=0
mydir=`pwd`
for i in $*
do
count=$(( $count + 1 ))
if [ $count -eq $# ]
then
temp=${temp}file://${mydir}/${i}
else
temp=${temp}file://${mydir}/${i},
fi
done

echo $temp

if thunderbird -remote "ping()" 2> /dev/null ;
then
thunderbird -remote "xfeDoCommand(composeMessage,attachment='$temp')"
else
thunderbird --compose "attachment='$temp'"
fi





Then just issue the command

bash attachs.sh filenames

Thursday, April 19, 2007

Setting new keyboard macro in emacs

The process is described here

Here is the final entry in your init.el file.


(fset 'newslide
[?\C-7 ?\C-7 ?% return ?% ?% ?% ?% ?% ?% ?% ? ? ?N ?E ?W ?\S- ?S ?L ?I ?D ?E return ?\C-7 ?\C-7 ?% return return ?\\ ?b ?e ?s ?{ ? ? ?} return return ?\\ ?e ?s return return])
(global-set-key [f8] 'newslide)



Now just press F8 and you will get an entry like

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% NEW SLIDE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\bes{ }

\es



which I used as demarcation while preparing latex slides

WOW you can type so much using just one key stroke :)

Wednesday, April 18, 2007

The Latex Bibtex cycle and camera ready postscript ( Shell file)


#! /usr/bin/tcsh -f
set file1 = ${1}
echo $file1

set file = $file1:r
latex $file
bibtex $file
latex $file
latex $file
dvips $file -P pdf -G0 -t letter -o
echo done latex bibtex latex latex

Split a postcript file with multiple pages of graphs and generate the code to include them in latex ( Shell file)


set j=1
while ($j <= $total )
psselect $j $file1 $file-$j.ps
echo "written $file-$j.ps"
echo "\includegraphics{$file-$j.ps}" >> $file.txt
set j=`expr $j + 1`
end
end

echo " "
echo " "

echo " Latex Code produced in $file.txt "

Convert all pdf file in adirectory to ps file ( Shell file)



#! /usr/bin/tcsh -f
foreach file ( *.pdf)
echo $file
pdf2ps $file
end

Print pdf from command line ( Shell file )


#!/bin/csh
if( $# == 2 ) then
set printer=$2
else
set printer=$PRINTER
endif

if( $1 != "" ) then
cat ${1} | acroread -toPostScript | lpr -P $printer
echo ${1} sent to $printer ... OK!
else
echo PDF Print: No filename defined!
endif

Interesting aliases



alias cleanthis '/bin/rm -f *.toc *.bbl *.blg *.pfg *.dvi *.aux *.log *~ #*# *.o .saves* .*~ core trash *.out *.bak'
alias clean 'source ~/script/clean.sh'
alias where 'find * -follow | grep $1'
alias sd 'setenv DISPLAY \!*":0"'
alias . 'exit'
alias pub 'chmod 755'
alias fon 'mv myforward .forward '
alias foff 'mv .forward myforward'
alias lsD 'ls -d */'


alias l. 'l `ls -t *.tex | head -1` &'
alias latex. 'latex `ls -t *.tex | head -1` &'
alias emacs. 'emacs `ls -t *.tex | head -1` &'
alias pdf. 'open `ls -t *.pdf | head -1` &'
alias gv. 'gv `ls -t *.ps | head -1` &'



Monday, April 2, 2007

Viewing or editing your recent file with clever aliases

You can get away without typing the full name for last file ( ps, pdf, tex) on the command line. Use the following aliases. I use them all the time: especially when I name your file
"04_11_mybestresearch_revision3.tex"


alias emacs. 'emacs `ls -t *.tex | head -1` &'
alias pdf. 'open `ls -t *.pdf | head -1` &'
alias gv. 'gv `ls -t *.ps | head -1` &'