655 lines
20 KiB
HTML
655 lines
20 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<html>
|
|
<head>
|
|
<title>More 2 Cent Tips & Tricks Issue 15</title>
|
|
</head>
|
|
|
|
<BODY BGCOLOR="#EEE1CC" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
|
|
ALINK="#FF0000" >
|
|
<H4>"Linux Gazette...<I>making Linux just a little more fun!</I>
|
|
"</H4>
|
|
<P> <hr> <P>
|
|
|
|
<!-- QUICK TIPS SECTION ================================================== -->
|
|
<center>
|
|
<H1><A NAME="tips"><IMG ALIGN=MIDDLE ALT="" SRC="../gx/twocent.gif">
|
|
More 2¢ Tips!</A></H1> <BR>
|
|
Send Linux Tips and Tricks to <A HREF="mailto:gazette@ssc.com">
|
|
gazette@ssc.com
|
|
</A></center>
|
|
|
|
<p><hr><p>
|
|
<H3>Contents:</H3>
|
|
<ul>
|
|
<li><a HREF="./lg_tips15.html#auto">Automatic Term Resizing</a>
|
|
<li><a HREF="./lg_tips15.html#back">Background Images</a>
|
|
<li><a HREF="./lg_tips15.html#change">Changing Directories</a>
|
|
<li><a HREF="./lg_tips15.html#color">Colorized Prompts</a>
|
|
<li><a HREF="./lg_tips15.html#less">Getting less to View gzipped Files</a>
|
|
<li><a HREF="./lg_tips15.html#lower">Lowercased Filenames</a>
|
|
<li><a HREF="./lg_tips15.html#more">More on Xterm Tittlebar Tip</a>
|
|
<li><a HREF="./lg_tips15.html#quick">A Quick & Dirty getmail Script</a>
|
|
<li><a HREF="./lg_tips15.html#syslog">Syslog 2c Tip Revised</a>
|
|
<li><a HREF="./lg_tips15.html#vi">vi/ed Tricks and the .exrc File </a>
|
|
</ul>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="auto"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Automatic Term Resizing
|
|
</H3>
|
|
<P>
|
|
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)<BR>
|
|
From: <A HREF="mailto:pb@europa.com">pb@europa.com </A>
|
|
<P>
|
|
Heya,<BR>
|
|
I spend a lot of time telnetting to my ISP from various sized terms
|
|
under X and from the good ol' prompt. Typing "stty cols x rows y" got
|
|
tedious, so I found a nice solution: Putting "eval `resize`" in my .cshrc.
|
|
Now my remote terms automatically resize themselves to whatever convoluted
|
|
geometry I've got locally.
|
|
<P>
|
|
Cheers,<P>
|
|
Peat
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="back"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Background Images
|
|
</H3>
|
|
<P>
|
|
Date: Tue, 18 Feb 1997 15:57:17 -0500 <BR>
|
|
From: Christopher Fortin, <A HREF="mailto:cfortin@bbn.com">
|
|
cfortin@bbn.com </A>
|
|
<P>
|
|
Hi.<BR>
|
|
I use fvwm2, and like to have four virtual screens,
|
|
each with a different background. However, I found myself editing
|
|
my .fvwm2rc file alot to change those backgrounds ( kept getting
|
|
bored with the selection ). So I came up with a little tcl
|
|
script to do the work for me. Now I just have a directory ( called
|
|
.backgrounds ) filled with .xpm files that I like as backgrounds.
|
|
On login, my .login file calls randBG.tcl, an executable tcl file
|
|
thats in your path, ( if tclsh is not in /usr/bin, change the first
|
|
line ).
|
|
<PRE>
|
|
#---CUT HERE------randBG.tcl---------------------------
|
|
#! /usr/bin/tclsh
|
|
|
|
proc randomInit {seed} {
|
|
global rand
|
|
set rand(ia) 9301; #multiplier
|
|
set rand(ic) 49297; #Constant
|
|
set rand(im) 233280; #Divisor
|
|
set rand(seed) $seed; #Last Result
|
|
}
|
|
|
|
proc random {} {
|
|
global rand
|
|
set rand(seed) \
|
|
[expr ($rand(seed)*$rand(ia) + \
|
|
$rand(ic)) % $rand(im)]
|
|
return [expr $rand(seed)/double($rand(im))]
|
|
}
|
|
|
|
proc randomRange { range } {
|
|
expr int([random]*$range)
|
|
}
|
|
|
|
randomInit [pid]
|
|
random
|
|
randomRange 100
|
|
|
|
### CHANGE THIS #####################
|
|
set BGDIR /your.home.dir/.backgrounds
|
|
#
|
|
|
|
exec /bin/rm -f $BGDIR/desk1.xpm
|
|
exec /bin/rm -f $BGDIR/desk2.xpm
|
|
exec /bin/rm -f $BGDIR/desk3.xpm
|
|
|
|
set files [ exec ls $BGDIR ]
|
|
set nfiles [llength $files]
|
|
|
|
set rnd1 [eval randomRange $nfiles]
|
|
set rnd1file [lindex $files $rnd1]
|
|
exec ln -s $BGDIR/$rnd1file $BGDIR/desk1.xpm
|
|
|
|
set rnd2 [eval randomRange $nfiles]
|
|
set rnd2file [lindex $files $rnd2]
|
|
exec ln -s $BGDIR/$rnd2file $BGDIR/desk2.xpm
|
|
|
|
set rnd3 [eval randomRange $nfiles]
|
|
set rnd3file [lindex $files $rnd3]
|
|
exec ln -s $BGDIR/$rnd3file $BGDIR/desk3.xpm
|
|
#------------
|
|
#-----CUT HERE-----------------------------------------
|
|
</PRE>
|
|
<P>
|
|
The rand part of this was from Welch's TCL book. Now you just
|
|
need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
|
|
|
|
<PRE>
|
|
#----------------------------------------------
|
|
####
|
|
# Set Up Backgrounds for different desktops.
|
|
####
|
|
Module FvwmBacker
|
|
|
|
*FvwmBackerDesk 0 xpmroot ./.backgrounds/desk0.xpm
|
|
*FvwmBackerDesk 1 xpmroot ./.backgrounds/desk1.xpm
|
|
*FvwmBackerDesk 2 xpmroot ./.backgrounds/desk2.xpm
|
|
*FvwmBackerDesk 3 xpmroot ./.backgrounds/desk3.xpm
|
|
#----------------------------------------------
|
|
</PRE>
|
|
|
|
and also
|
|
<PRE>
|
|
#----------------------------------------------
|
|
AddToFunc "InitFunction" Desk "I" 0 0
|
|
+ "I" Exec xpmroot ./.backgrounds/desk0.xpm &
|
|
#----------------------------------------------
|
|
|
|
to set desk0 prior to changing between desks. Just a little
|
|
hack I thought someone might like. Note that this only changes
|
|
desks 1-3, since I tend to keep desk0 constant ( I found a
|
|
*really* nice background ).
|
|
</PRE>
|
|
Chris <BR>
|
|
-- Dr. Christopher S. Fortin
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="change"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Changing directories, A short enhancement to previous article's idea
|
|
</H3>
|
|
<P>
|
|
Date: Thu, 20 Feb 1997 19:13:38 +0100 <BR>
|
|
From: jurriaan, <A HREF="mailto:thunder7@xs4all.nl">thunder7@xs4all.nl </A>
|
|
<P>
|
|
In an article in the October Linux Journal (or was it Gazette - I
|
|
don't know) by Marc Ewing (marc@redhat.com) a shell script was presented
|
|
to allow a user to go to any directory on the system, without getting to
|
|
all directories in between.
|
|
<P>
|
|
Much as this script apealed to me, it didn't work as I expected:
|
|
<P>
|
|
(A part of) my directory tree look like:
|
|
<PRE>
|
|
/root
|
|
/root/angband
|
|
/root/angband/2796
|
|
/root/angband/2796/src
|
|
/root/angband/2796/lib
|
|
/root/angband/2796/lib/edit
|
|
/root/angband/2796/lib/data
|
|
/root/angband/myang
|
|
/root/angband/myang/src
|
|
/root/angband/myang/lib
|
|
/root/angband/myang/lib/edit
|
|
/root/angband/myang/lib/data
|
|
etc.
|
|
</PRE>
|
|
|
|
Now when I typed cds myang, it offered me a choice between all
|
|
directories containing myang. Instead I'd much prefer if the program
|
|
decided that the one directory ending in myang would be the most logical
|
|
choice.
|
|
<P>
|
|
I adapted this script, and the result is included below. Many comments
|
|
are added, which you may or may not like. They may not even be correct,
|
|
as I am not one of the guru-est of linux-dom, as Marc Ewing was described
|
|
:-).
|
|
<P>
|
|
If you like it, use (ie include) it and let me know please.
|
|
<P>
|
|
If you don't, adapt it and then include it and let me know please.
|
|
<P>
|
|
If you really don't like it, consider this message not written.
|
|
<P>
|
|
Greetings from Holland, <BR>
|
|
Jurriaan (thunder7@xs4all.nl)
|
|
|
|
<PRE>
|
|
function cds() {
|
|
# no arguments? then do nothing
|
|
if [ $# -ne 1 ]; then
|
|
echo "usage: cds pattern"
|
|
return
|
|
fi
|
|
|
|
# $1 seems to disappear later on, or change value, so we declare a real
|
|
target
|
|
target=$1
|
|
|
|
# find $target in file $HOME/.dirs
|
|
set "foo" `fgrep $target $HOME/.dirs`
|
|
|
|
# $# is the function return status, 1 means not found
|
|
if [ $# -eq 1 ]; then
|
|
echo "No matches"
|
|
|
|
# 2 means just one found
|
|
elif [ $# -eq 2 ]; then
|
|
cd $2
|
|
|
|
# we found a couple of possible directories
|
|
else
|
|
|
|
# $ is the sign for end-of-line , -E tells fgrep to use extended regular
|
|
# expressions
|
|
# the \ before $ tells the shell not to see $ as an empty variable, but to
|
|
# pass it right on to fgrep
|
|
# if you are ever in doubt, use set -x to see what goes on in your scripts.
|
|
# then use set +x to get rid of all the extra output
|
|
set "foo" `fgrep -E $target\$ $HOME/.dirs`
|
|
|
|
# we found a directory at the end of the tree, ie myang$ selects
|
|
# /root/angband/myang, but not /root/angband/myang/src.
|
|
if [ $# -eq 2 ]; then
|
|
cd $2
|
|
|
|
# I'm not sure - in DOS you must reset your variables, in Linux too?
|
|
target=
|
|
return
|
|
else
|
|
|
|
# this is a copy of the original function: search for a match, even if it
|
|
# is in the middle of a directory
|
|
# one extra trick: we first count how many matches we find, using fgrep -c
|
|
count=`fgrep -c $target $HOME/.dirs`
|
|
|
|
# stty size gives on my terminal 51 116 (ie a 116x51 screen)
|
|
# cut -b1-3 gives then 51
|
|
lines=`stty size | cut -b1-3`
|
|
|
|
# if more than 2/3 of the terminal, it's too much
|
|
lines=$[$lines*2/3]
|
|
if [ $count -gt $lines ]; then
|
|
echo "More than $lines matches - respecify please"
|
|
count=
|
|
lines=
|
|
target=
|
|
return
|
|
fi
|
|
|
|
# else we really go for it, just like the old version
|
|
set "foo" `fgrep $target $HOME/.dirs`
|
|
shift
|
|
for x in $@; do
|
|
echo $x
|
|
done | nl -n ln
|
|
echo -n "Number: "
|
|
read C
|
|
if [ "$C" = "0" -o -z "$C" ]; then
|
|
return
|
|
fi
|
|
eval D="\${$C}"
|
|
if [ -n "$D" ]; then
|
|
#echo $D
|
|
cd $D
|
|
fi
|
|
fi
|
|
fi;
|
|
}
|
|
</PRE>
|
|
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="color"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Colorized Prompts
|
|
</H3>
|
|
<P>
|
|
Date: Mon, 24 Feb 1997 12:03:57 <BR>
|
|
From: <A HREF="mailto:arnim@rupp.de">arnim@rupp.de </A>
|
|
<PRE>
|
|
#!/bin/sh
|
|
|
|
# script for colorized prompts, by arnim@rupp.de
|
|
|
|
# start this script to see all possible colors then
|
|
# include this ...
|
|
# ------------------------- snip ------------------------
|
|
|
|
BLACK='^[[30m'
|
|
RED='^[[31m'
|
|
GREEN='^[[32m'
|
|
YELLOW='^[[33m'
|
|
BLUE='^[[34m'
|
|
MAGNETA='^[[35m'
|
|
CYAN='^[[36m'
|
|
WHITE='^[[37m'
|
|
|
|
BRIGHT='^[[01m'
|
|
NORMAL='^[[0m'
|
|
|
|
# blink ;-)
|
|
BLINK='^[[05m'
|
|
REVERSE='^[[07m'
|
|
|
|
# sample bash-prompt
|
|
PS1=$BRIGHT$YELLOW'\u:'$NORMAL'/\t\w\$ '
|
|
|
|
# ------------------------- snip ------------------------
|
|
# .. in Your /etc/profile, .profile, .bashrc, .whatever, ...
|
|
# ( don't cut & paste with the mouse, this would spoil the escape-characters )
|
|
|
|
echo $BLACK 'BLACK'
|
|
echo $RED 'RED'
|
|
echo $GREEN 'GREEN'
|
|
echo $YELLOW 'YELLOW'
|
|
echo $BLUE 'BLUE'
|
|
echo $MAGNETA 'MAGNETA'
|
|
echo $CYAN 'CYAN'
|
|
echo $WHITE 'WHITE'
|
|
|
|
echo $BRIGHT$BLACK 'BRIGHT BLACK'
|
|
echo $BRIGHT$RED 'BRIGHT RED'
|
|
echo $BRIGHT$GREEN 'BRIGHT GREEN'
|
|
echo $BRIGHT$YELLOW 'BRIGHT YELLOW'
|
|
echo $BRIGHT$BLUE 'BRIGHT BLUE'
|
|
echo $BRIGHT$MAGNETA 'BRIGHT MAGNETA'
|
|
echo $BRIGHT$CYAN 'BRIGHT CYAN'
|
|
echo $BRIGHT$WHITE 'BRIGHT WHITE'
|
|
|
|
echo $NORMAL
|
|
</PRE>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="less"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Getting less to View gzipped Files
|
|
</H3>
|
|
<P>
|
|
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)<BR>
|
|
From: Michael Bain, <A HREF="mailto:michael.bain@boeing.com">
|
|
michael.bain@boeing.com </A>
|
|
<P>
|
|
Here's how to use less to view gzipped files. Also, there
|
|
is a way you can use this less feature that doesn't require
|
|
temporary files and only needs one script file.
|
|
<P>
|
|
Put lesspipe.sh in your executable path.
|
|
<P>
|
|
lesspipe.sh:
|
|
<PRE>
|
|
#! /bin/sh
|
|
case "$1" in
|
|
*.Z) uncompress -c $1 2>/dev/null
|
|
;;
|
|
*.gz) gunzip -c $1 2>/dev/null
|
|
;;
|
|
esac
|
|
</PRE>
|
|
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
|
|
(Don't forget the pipe '|' symbol.)
|
|
This works with less version 2.90.
|
|
<P>
|
|
Michael Bain
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="lower"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Lowercased Filenames
|
|
</H3>
|
|
<P>
|
|
Date: Thu, 20 Feb 1997 00:38:10 GMT <BR>
|
|
From: <A HREF="mailto:bubje@freemail.nl">bubje@freemail.nl </A>
|
|
<P>
|
|
Hello there <BR>
|
|
We've all read all those ways to convert uppercased filenames to lowercased ones. But why did we need it?
|
|
One reason is because when we unzip a file, all filenames are uppercase.
|
|
Well, try this (much much shorter :) )
|
|
<PRE>
|
|
unzip -L filename.zip
|
|
</PRE>
|
|
This extracts the files as usual, but converts the filenames to lowercase, so there's no need to run any of those other two cent tips anymore...
|
|
(and it's less to type, and faster)
|
|
<P>
|
|
Greatz <BR>
|
|
Jan Gyselinck, <A HREF="mailto:wodan@cryogen.com">
|
|
wodan@cryogen.com </A>
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="more"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
More on Xterm Titlebar Tip
|
|
</H3>
|
|
<P>
|
|
Date: Tue, 11 Feb 1997 12:33:18 -0500 <BR>
|
|
From: Raul D. Miller, <A HREF="mailto:rdr@tad.micro.umn.edu">
|
|
rdr@tad.micro.umn.edu </A>
|
|
<P>
|
|
I don't know if you've touched on this yet -- if so, please ignore this
|
|
message.
|
|
<P>
|
|
With bash, you can reliably set the titlebar. Just set the
|
|
PROMPT_COMMAND variable to be a command that sets your title bar.
|
|
<P>
|
|
Aside: I usually use the shortened host name, with a # suffix if I'm
|
|
root. The most portable way of testing if I'm root is [ -w / ]
|
|
<P>
|
|
Raul
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="quick"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
A Quick and Dirty getmail Script
|
|
</H3>
|
|
<P>
|
|
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)<BR>
|
|
From: Markku J. Salama, <A HREF="mailto:msalama@hit.fi">
|
|
msalama@hit.fi </A>
|
|
<P>
|
|
Hi there!
|
|
<P>
|
|
Here is a quick and dirty script for fetching your mail without a POP
|
|
account. It does it's thing by using telnet and ftp.
|
|
<PRE>
|
|
--------------------------------BEGIN SCRIPT------------------------------
|
|
|
|
#!/bin/sh
|
|
# Brought to you by msalama@superfly.salama.fi
|
|
# Caveat emptor: You use this entirely at your own risk, I'm not
|
|
# responsible for any damages or loss of mail it might cause.
|
|
|
|
# There are 3 things to remember:
|
|
|
|
# 1) Make sure this script is readable & executable _only_ by you, it
|
|
# contains password information!
|
|
|
|
# 2) You must have a .netrc-file in your home directory containing a
|
|
# hostname, your username and your passwd for ftp. Make sure this file
|
|
# is readable _only_ by you, too, and check the ftp man page for
|
|
# details.
|
|
|
|
# 3) You must, of course, edit this script to provide all the necessary
|
|
# passwords, usernames etc. for telnet. Also, the remote system must
|
|
# have dd installed to empty the mailbox.
|
|
|
|
(echo open your.host # The sleeps are necessary so that telnet
|
|
sleep 5 # doesn't get confused
|
|
|
|
echo your.username
|
|
sleep 5
|
|
|
|
echo your.password # For your eyes only...
|
|
sleep 10 # 10 sec. break, let the motd etc. scroll by
|
|
|
|
echo cp /remote/mailbox/file ./newmail # copy the mailbox file into
|
|
sleep 5 # your remote home directory
|
|
|
|
echo dd if=/remote/mailbox/file of=/remote/mailbox/file # Empty the
|
|
sleep 5 # mailbox
|
|
|
|
echo quit) | telnet -8E > /dev/null
|
|
|
|
(echo binary # Now go get the mail using
|
|
echo get newmail # ftp. Handy for those folks
|
|
echo delete newmail # who don't have a POP account.
|
|
echo bye) | ftp your.host > /dev/null
|
|
|
|
mv ./newmail /local/mailbox/file # Move the new mail in place...
|
|
|
|
chmod go-rwx /local/mailbox/file # Just in case it's readable
|
|
# by someone else.
|
|
# All done! Go read them.
|
|
|
|
--------------------------------END SCRIPT--------------------------------
|
|
</PRE>
|
|
There. Have a nice spring & be an excellent person.
|
|
<P>
|
|
Markku Salama
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="syslog"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
Syslog 2c Tip Revised
|
|
</H3>
|
|
<P>
|
|
Date: Sun, 9 Feb 1997 23:26:46 -0800 (PST)<BR>
|
|
From: Ian Main, <A HREF="mailto:imain@vcc.bc.ca">
|
|
imain@vcc.bc.ca </A>
|
|
<P>
|
|
Hi, just going through issue #14 of the linux gazzette, and I noticed the
|
|
tip on logging *.* to a file so you can read it in an rxvt in X. I do a
|
|
similar thing here, but rather than logging to a file, I log to a pipe (ah
|
|
ha! Why didn't I think of that? :-) ).
|
|
<P>
|
|
Works really well. No disk space used, and you can just use cat to view
|
|
it, and it scrolls along nicely.
|
|
<P>
|
|
To make a named pipe (FIFO) in /var/log/message-pipe:
|
|
<PRE>
|
|
mknod /var/log/message-pipe p
|
|
</PRE>
|
|
and add this to your /etc/syslog.conf (note the pipe symbol there.) :
|
|
<PRE>
|
|
*.* |/var/log/message-pipe
|
|
</PRE>
|
|
and finally, just type:
|
|
<PRE>
|
|
cat /var/log/message-pipe
|
|
</PRE>
|
|
Or of course.. you can stick it in a shells script or as the command rxvt
|
|
runs when it starts.. whatever you like.
|
|
<P>
|
|
Hope you find it useful,
|
|
<P>
|
|
Ian
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
|
|
<a name="vi"></a>
|
|
<H3><IMG ALIGN=BOTTOM ALT="" SRC="../gx/lil2cent.gif">
|
|
vi/ed Tricks and the .exrc File
|
|
</H3>
|
|
<P>
|
|
Date: Tue, 11 Feb 1997 16:28:30 -0600 (CST)<BR>
|
|
From: Sean Murray, <A HREF="mailto:murrsea@ripco.com">
|
|
murrsea@ripco.com </A>
|
|
<P>
|
|
The vi editor is built on the foundations of the "ed" editor. Whatever
|
|
applies to ed applies to vi. So if you where wondering if there was a
|
|
way to customize your vi sessions wonder no longer.
|
|
<P>
|
|
In your home directory create a file called ".exrc", every time vi
|
|
starts it will parse that file and customize it's actions. The below 5
|
|
lines are the contents of my .exrc file.
|
|
<PRE>
|
|
set tabstop=8
|
|
map ^N {!}sort^M
|
|
map v {^M!}fmt^M
|
|
map V 1G^M!Gfmt^M
|
|
map ^W :!ispell %^M^M:e!^M
|
|
</PRE>
|
|
I didn't include any comments because I don't know if the .exrc file
|
|
has a comment character, I'll comment theses lines later?
|
|
<P>
|
|
Ok the "set" command allows you to set various parameters in vi; in
|
|
this case I've set the tab stop to 8 characters. So when ever I enter a
|
|
tabstop in insertion mode the cursor will move over 8 spaces (8 spaces
|
|
is what most printers will print tabs at regardless of your vi
|
|
settings). But you can set it to what ever you like.
|
|
<P>
|
|
Sometimes when programming I manually set my tabstop to 4 spaces for
|
|
indentation. To do this type in the following ":set tabstop=4". The
|
|
nice thing about this is that the character is still really a tab and
|
|
not a bunch of spaces, hence you don't force other ppl to view text
|
|
with your spacing.
|
|
<P>
|
|
"map" maps a key or key combination to a sequence of commands. Note:
|
|
that only ed commands work here so see view a list of ed commands while
|
|
editing your .exrc file. It's a BAD idea to map key or key combinations
|
|
that already have other meanings. The available combinations are:
|
|
<PRE>
|
|
letters: "g K k q V v"
|
|
Control keys: "^A ^K ^O ^T ^W ^X"
|
|
(where "^A" means press the control key and the letter a)
|
|
Symbols: "_ * \ ="
|
|
</PRE>
|
|
(These above four lines where shamelessly stolen from ORA's _Learning
|
|
the Vi Editor_; it's a must get for any vi user)
|
|
<P>
|
|
So what does "map ^W :!ispell %^M^M:e!^M" do -- well the "map" is the
|
|
keyword telling vi to map the next character to the following
|
|
commands. (If you map a key combination like ^W then remember to enter
|
|
this by typing the control key and "v" first and then the key
|
|
combination of control key and the letter "w".) Here we are mapping ^W
|
|
to a set of commands. The first command is telling vi to execute the
|
|
external program ispell with the current file we are editing (the
|
|
variable that holds the current files name is "%"). The ^M is actually
|
|
the character that appears after you have typed ^V and then typed the
|
|
return key hence ^M denotes the instance of a carriage return. The last
|
|
command is the vi command to reload the current file; this is necessary
|
|
as the ispell program will update the file and not the vi buffer.
|
|
<P>
|
|
assuming that you have the external programs "ispell", "fmt" and "sort"
|
|
the theses mappings should work. "map ^N {!}sort^M" will sort a
|
|
paragraph. "map v {^M!}fmt^M" will format a paragraph. "map V
|
|
1G^M!Gfmt^M" will format the whole document.
|
|
<P>
|
|
A final note: if you have the environment variable EXINIT set it will
|
|
take precedence over the .exrc file settings.
|
|
<P>
|
|
Sean Murray
|
|
|
|
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
<center>Published in Linux Gazette Issue 15, March 1997</center>
|
|
<P> <hr> <P>
|
|
<!--================================================================-->
|
|
<A HREF="./index.html"><IMG SRC="../gx/indexnew.gif" ALT="[ TABLE OF
|
|
CONTENTS ]"></A> <A HREF="../index.html"><IMG SRC="../gx/homenew.gif"
|
|
ALT="[ FRONT PAGE ]"></A> <A HREF="lg_mail15.html"><IMG SRC="../gx/back2.gif" ALT=" Back "></A>
|
|
<A HREF="lg_bytes15.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
|
|
|
|
<P> <hr> <P>
|
|
<h5>This page maintained by the Editor of <I>Linux Gazette</I>,
|
|
<A HREF="mailto: gazette@ssc.com">gazette@ssc.com</A><BR>
|
|
Copyright © 1997 Specialized Systems Consultants, Inc. </H5>
|
|
<P>
|
|
</body>
|
|
</html>
|