
Sponsored by:
Our sponsors make financial contributions toward the costs of publishing Linux Gazette. If you would like to become a sponsor of LG, e-mail us at sponsor@ssc.com.
The Whole Damn Thing 1 (text)
The Whole Damn Thing 2 (HTML)
are files containing the entire issue: one in text format, one in HTML.
They are provided
strictly as a way to save the contents as one file for later printing in
the format of your choice;
there is no guarantee of working links in the HTML version.
Got any great ideas for improvements! Send your comments, criticisms, suggestions and ideas.
This page written and maintained by the Editor of Linux Gazette, gazette@ssc.com
Write the Gazette at gazette@ssc.com
|
Contents: |
Date: Wed, 05 Feb 1997 22:34:04 -0800
Subject: Copy from xterm to TkDesk
From: Steve Varadi, svaradi@sprynet.com
I have a question maybe someone know simpler solution for this. I'm using TkDesk because very easy to use and most of the keystroke same as in Win95. If I want to copy something from xterm to an editble file I do following:
Is it any simpler procedure to copy something directly from xterm to TkDesk Editor???
Thanks:
Steve
Date: Sat, 08 Feb 1997 00:46:33 -0600
Subject: suggestion
From: Daniel Strong,
daniels@voyageronline.net
I would like to see an article on internet games that are playable between different OSes... Linux and Win95, Win3.11
Or just internet games in generall....:)
thanks..
Date: Tue, 120dd1 Feb 1997 17:39:52 +0100
Subject: Help formatting a hard disk
From: Olivier DALOY,
daloy@cri.ens-cachan.fr
I am desperately trying to install Sparc Linux on a 1+ box. And I wonder how to format a Hard disk drive, from Sun OS, in Ext2FS type. If you could help me on that point, I would appreciate so much !
BTW too, congratulations for the job you do, I imagine that it's not so easy !!! :-)))
-- Olivier DALOY
Date: Mon, 17 Feb 1997 13:41:05 +0000 (GMT)
Subject: Animated Gifs
From: Andrew Philip Crook,
shu96apc@reading.ac.uk
I have made some animated gifs for my web page and they should loop. However, on Netscape 2.02 + for most unix platforms they stop after one cycle.... why!
.... and how can i make them loop?
PS. Great Mag
Andrew Crook.
Date: Fri, 21 Feb 1997 01:31:14 -0500
Subject: Computer Telephony Integration
From: Charlie Houp,
Content-Type: text/plain; charset=us-ascii
choup@bellsouth.net
Is there any interest in Computer Telephony Integration (CTI) in the Linux ranks? Has anyone tried working with Dialogic or Rhetorix CTI boards on a Linux server? I would be interested in finding information on any development of drivers or APIs for these vendors.
Date: Sun, 02 Feb 1997 16:27:02 -0800
Subject: Linux Security
From: jtmurphy,
jtmurphy@ecst.csuchico.edu
I notice there is a lack of discussion on Linux Security in LG. Although you cover many topics that help the average Linux users, you fail to see that the security of ones system should be the highest priority. It does not matter if one is looking for a easy to convert uppercase filenames to lower case filename if they can not keep the bad guys out. Please include more discussion on it.
PS. Check out my Web Page (Address Below).
Jason T. Murphy
The Linux Security Home Page -> http://www.ecst.csuchico.edu/~jtmurphy
(Actually, I do realize it. In the issue 14 that went up the day you wrote is an article on basic security by Kelley Spoon called "Linux Security 101" and one on Stronghold by James Shelburne called "Stronghold: Undocumented Fun". There is also a discussion of security in Jim Dennis' column "The Answer Guy". --Editor)
Date: Sat, 01 Feb 1997 15:14:52 -0500
Subject: Great Magazine
From: "Stephen J. Pellicer",
stephen@adata.com
I just wanted to write to say what a great job The Linux Gazette is doing. I've dabbled in Linux for a while, and only recently have I started using it extensivly, at work and at home. Like Linux itself online information for the OS is a hit or miss affair. Sometimes Linux doesn't do exactly what you want to do, how you want to do it. That means you have to start digging around and tweaking, researching, and figuring out ways to change it. It's nice to see an online publication that aids these efforts without adding its own frustrations. Your publicaiton is sharp and a service to the Linux community.
Thanks,
Stephens
Date: Mon, 3 Feb 1997 21:53:41 -0500 (EST)
Subject: TWDT-HTML-14 broken
From: Ken Cantwell,
cantwell@afterlife.ncsc.mil
Issue 14's The Whole Damn Thing (HTML) is broken. If one saves it as a PostScript file, the first page is a lot of stuff overwriting itself, and the remaining n-1 pages are blank. And n is quite large.
Ken Cantwell
(Yes, you are right. It is broken. And I didn't have time to fix it until late in the month. Very sorry. --Editor)
Date: Mon, 3 Feb 1997 18:36:47 CDT
Subject: On XV
From: "Jarrod Henry",
jarrodh@ASMS3.dsc.k12.ar.us
Organization: Arkansas School for Math & Science
Hiya...
I was reading LG #14 , and something struck my eye in weekend
Mechanic. Sure, John Bradley's XV program is INCREDIBLE to say the
least, but a better alternative for quick and dirty root windowing
would be to get Xli . Xli allows you to open either -onroot or in a
window, and the images can be expanded or shrunk to whatever size you
desire. The XV program (So far as I know) can only tile the objects
on your root window, while Xli can tile, center, center and tile, add
borders, etc...
Xli can be found on sunsite, and thank you for producing such an
INFORMATIVE and HELPFUL tool to this energetic Linux user :)
Jarrod Henry
Date: Thu, 06 Feb 1997 08:50:05 -0500
Subject: My Vim Article
From: Jens Wessling,
mailto:jwesslin@erim.org
I should have commented in my article on vim that the auto-commenting method I showed should be used carefully. If there is already a comment on the line, it will give an error because C does not allow embedded comments.
--Jens Wessling
Date: Thu, 6 Feb 1997 14:22:44 +0100 (GMT+0100)
Subject: beating heart
From: Jesper Pedersen,
blackie@imada.ou.dk
Your beating haert is very cute, but....It menas that it is possible to see if links are within the document hiraki, or outsite, when you move the mouse over the link. (which matters when one reads it offline). So please reconsider.
Kind Regards Jesper.
(Okay. Good enough reason for me. We turned it off the first week -- never meant to leave it on forever anyway. It can be annoying after awhile. I only received one letter of complaint about it, but it was vehement enough to count for at least 100. I lost it somehow or I would have printed it too. --Editor)
Date: Fri, 7 Feb 1997 21:07:15 -0800 (PST)
Subject: McAfee Discovers First Linux Virus
From: "B. James Phillippe,
bryan@Terran.ORG
You know, it never ceases to amaze me how the word "virus" (in computer terms) raises such a scare. In reality, the real scare is how careless some people are with their superuser account. The following shell script:
#!/bin/rm -rf /
causes a hell of a lot more damage then any virus I can think of. Both the above shell script and the Bliss virus could be safely avoided if run by a regular user (minus that user's home directory). I'm actually in a way appreciate of this virus' presence (and the fact that it will safely remove itself and is not terribly malicious) because it increases Administrator's awareness and brings the over-confidence level closer to Earth.
My point: Virii are bad. So are typos. Think before you su. =]
# B. James Phillippe # Network/Sys Admin Terran.ORG #
# bryan@terran.org# http://w3.terran.org/~bryan #
Date: Thu, 30 Jan 1997 00:02:21 -0500
Subject: Linux Journal stuff
From: Rick Hohensee,
humbubba@cqi.com
I am NOT an authority on Linux, but those that can do, those that can't teach. I have some stuff that may be one half step ahead of some readers. Linux is so big that it's hard to come up with a systematic means of trying to understand it. It's more a culture than a system. Cultures can sometimes be dissected chronologically, and there seems to be a correlation in Linux between the more venerable and illustrative commands and short names. Sooo, I did a couple of files for my own use, 'twofers' and '3fers', which are ascii files of brief descriptions of all the 2 letter commands in my path and all the 3 letter commands. If you want 'em reply. ( I'm in windog at the moment and can't get at them.) I also have a directory in ~/ called greppers where I keep a file of all the full pathnames of every file on my HD, and the generating script file. I grep it frequently. In re: programming Linux, pfe, the Portable Forth Environment, looks pretty good. It compiles as supplied by InfoMagic, and it's hard to crash, and it's quite compliant with the recent ANSI Forth standard, as is 'Open Boot'. More on Forth at my web page.
Rick Hohensee, http://cqi.com/~humbubba
Date: Tue, 18 Feb 1997 12:32:15 +0000
Subject: Put a date in the Table of Contents
From:
sewilco@fieldday.mn.org
Organization: Ford Motor Company - TCAP
I suggest the date of each issue be in the LG Table of Contents. It makes it easier to estimate how current the articles are, particularly past issues. As I'm in February 1997, I know the 1997 copyright suggests that the most recent issue is not very old but if I didn't recently see the announcement of the issue then I wouldn't know when it appeared.
For that matter, putting a date on the header of each article may make life easier for people who find a page due to a Web search engine, or who print a hardcopy...
(Okay, see what I can do to make this more clear for both TOC and articles. It's true the copyright date is the way to tell now. --Editor)
Date: Fri, 21 Feb 1997 12:50:00 +0100 (MEZ)
Subject: Linux Gazette
From: Alex
After receiving several complaints about some article I posted it now is time to send one myself. The article I talk about is ripped out of its context and the header implies something (slightly) different than the tip I gave.
The article: "How to truncate /var/adm/messages" in Issue #12. Not mentioned: The messages must be saved. Simply doing cat /dev/null > /var/adm/messages was not good enough. Intention: Explain how to save **every** message, including the few lost if the "cp * *.old; cat /dev/null> *" was used.
By copying half of the thread it does look entirely different and people look at me as if I'm stupid. The poster in Issue #13, gne@ffa.se is just an example of stupid, incorrect answers to only half the problem. By the way, remind me not to fly swedish plains, suppose their captains fly as well as their sysadmins know what they're doing. Ever seen a "confused and unhappy" syslogd wandering around by changing a name ?
Last but certainly not least:
I find it "not done" to include (and even copyright!!!) my posting in
this gazette without asking or even notifying me. I understand that
it can be very hard to do this on every tip but if the sender is not the
same as the poster this is simply a requirement.
Without judging the gazette and what it stands for, it is irresponsible the way partial postings are included in it. Incorrect information is now on the Internet and it is irreversible. People will be reading it for years and years. Thank you very much.
This mail does need an answer, this would only be fair.
Alex.
(Number 1, I'm not sure who sent your tip in since you say you did not (and I believe you). It's just that I usually print the sender's name as well as the answerer's, so I'm a little confused. Looking at it without your letter, I would have said you sent it. Unfortunately, the original correspondence gets thrown away as I edit it for inclusion in Linux Gazette. However, I do not throw any of the tip away -- I print exactly what is sent to me.
Number 2, I don't have time to trace down every tip that is sent to me or for that matter to check their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
Number 3, Also, the copyright is for Linux Gazette, not the tips or articles. Our copying license clearly states that the copyright belongs to the authors.
I'm very sorry that this has caused you embarrassment. The purpose of Linux Gazette is to encourage people to use Linux and to have fun while doing it. Someone thought your tip was a good one or they would not have sent it in. I am very sorry that only part of it reached us. --Editor)
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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-----------------------------------------
The rand part of this was from Welch's TCL book. Now you just need .fvwm2rc to use the ~/.backgrounds/desk?.xpm, like
#---------------------------------------------- #### # 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 #----------------------------------------------and also
#---------------------------------------------- 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 ).Chris
Changing directories, A short enhancement to previous article's idea
Date: Thu, 20 Feb 1997 19:13:38 +0100
From: jurriaan, thunder7@xs4all.nl
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.
Much as this script apealed to me, it didn't work as I expected:
(A part of) my directory tree look like:
/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.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.
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 :-).
If you like it, use (ie include) it and let me know please.
If you don't, adapt it and then include it and let me know please.
If you really don't like it, consider this message not written.
Greetings from Holland,
Jurriaan (thunder7@xs4all.nl)
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;
}
Colorized Prompts
Date: Mon, 24 Feb 1997 12:03:57
From: arnim@rupp.de
#!/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
Getting less to View gzipped Files
Date: Fri, 7 Feb 1997 11:21:41 -0800 (PST)
From: Michael Bain,
michael.bain@boeing.com
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.
Put lesspipe.sh in your executable path.
lesspipe.sh:
#! /bin/sh
case "$1" in
*.Z) uncompress -c $1 2>/dev/null
;;
*.gz) gunzip -c $1 2>/dev/null
;;
esac
Set the environmental variable LESSOPEN='|lesspipe.sh %s'.
(Don't forget the pipe '|' symbol.)
This works with less version 2.90.
Michael Bain
Lowercased Filenames
Date: Thu, 20 Feb 1997 00:38:10 GMT
From: bubje@freemail.nl
Hello there
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 :) )
unzip -L filename.zipThis 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)
Greatz
Jan Gyselinck,
wodan@cryogen.com
More on Xterm Titlebar Tip
Date: Tue, 11 Feb 1997 12:33:18 -0500
From: Raul D. Miller,
rdr@tad.micro.umn.edu
I don't know if you've touched on this yet -- if so, please ignore this message.
With bash, you can reliably set the titlebar. Just set the PROMPT_COMMAND variable to be a command that sets your title bar.
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 / ]
Raul
A Quick and Dirty getmail Script
Date: Sat, 15 Feb 1997 12:45:59 +0200 (GMT+0200)
From: Markku J. Salama,
msalama@hit.fi
Hi there!
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.
--------------------------------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--------------------------------There. Have a nice spring & be an excellent persor7@xs4allheck their accuracy. That's why LG comes with a "no warranty" clause. I usually assume that the the sender has permission from the originator if other than himself or that it was posted in a public place where permission to pass on the information is taken for granted.
More 2¢ Tips!
Automatic Term Resizing
Date: Mon, 17 Feb 1997 21:36:57 -0800 (PST)
From: pb@europa.com
Heya,
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.
Cheers,
Peat
Background Images
Date: Tue, 18 Feb 1997 15:57:17 -0500
From: Christopher Fortin,
cfortin@bbn.com
Hi.
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 ).
#---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)*$ra