]> sipb.mit.edu Git - wiki.git/blobdiff - doc/barnowl_random_zsigs.mdwn
(no commit message)
[wiki.git] / doc / barnowl_random_zsigs.mdwn
index 8accead3c3d33fb96d1e4cf3c27adf87c22e25e0..cc98688f8ad3600d2adaa46279d052c0f2a8661f 100644 (file)
@@ -1,6 +1,8 @@
 [[!meta title="Random Zsigs for Barnowl"]]
 
-# Random Zsigs for Barnowl
+## Random Zsigs for Barnowl
+
+Note: There's a lot of background information in here which can be bypassed.
 
 First off, if you haven't already, take a look at Barnowl's internal documentation. Try the following two commands.
        
@@ -23,17 +25,14 @@ Most people keep it that way, since people may not immediately know who you are
        
 (Barnowl accepts either single or double quotes to enclose your zsig, allowing you to use the other type of quote inside your zsig. Experiment, Barnowl tells you what it interpreted your command as by showing as confirmation
 
-       zsig = 'This is a very interestin' quote.'
-       
-
+       zsig = 'This is a very interestin' quote.'      
 
 ### Random Zsig Generator
 But what if you want to set up a random zsig generator?
 
-In outline, you write some code that prints a zsig out to `stdout`, then set up Barnowl to run that code, take the [stdout](http://en.wikipedia.org/wiki/Stdout#Standard_output_.28stdout.29), and [pipe](http://en.wikipedia.org/wiki/Unix_pipe) it into your zsig. 
-(If you're not sure what piping or stdout is, just follow along--the wikipedia articles are kind of technical. Otherwise you probably already know everything you need to know and can stop reading this).
+In outline, we use some bash magic that prints a zsig out to `stdout`, then set up Barnowl to run that bit of bash magic. Barnowl has something already which will automagically take that `stdout` and pipe it into your zsig.
 
-#### Steps Outside of Barnowl: Creating the zsigs file and the zrandom program
+#### Steps Outside of Barnowl: Creating the zsigs file
 Connect to Athena if you haven't already.
 
 1. Create a file of zsigs. In this article we'll call the file `.zsigs`
@@ -43,27 +42,13 @@ Connect to Athena if you haven't already.
                a zsig
                random zsig2
                random234
-               
-3. Now create a file to store your code, named for instance  `.zrandom`
 
-4. Write a program that randomly picks zsigs from your file and prints them out (to stdout), for instance:
+3. If you want to, test the bit of bash magic we'll be using
 
-               #!/usr/athena/bin/python
-               import random
-               zfile = open('.zsigs')
-               linelist = zfile.read().splitlines()
-               zfile.close()
-               print random.choice(linelist)
-       
-       If you want to use another language (e.g. perl or C), or check out what version is running on Athena, see [What Runs Where on Athena: Languages - IS&T] (http://web.mit.edu/acs/www/languages.html) and just swap out the first line with the language you want. See also [Random Zsigs - iZephyr](http://stuff.mit.edu/afs/sipb/project/doc/izephyr/html/node35.html) for more example programs (note the instructions are outdated).
-
-5. If you want to, test your program.
-
-               kusername@dr-wily:~$ python .zrandom
+               kusername@dr-wily:~$ shuf -n1 ~/.zsigs
                random zsig2
        
        The second line should be one of the zsigs from your list. Run it multiple times if you want to check for randomness.
-       
 
 #### Setting Up Barnowl: Using the zsigproc variable
 ##### Background
@@ -87,10 +72,10 @@ We will also use the `:startup` command, which is described in
        
 ##### The Steps
 
-1. Use the `:startup` command in Barnowl to write to the "~/.owl/startup" file (or wherever you decided to put the your startup settings file for Barnowl). (Alternatively, edit the "~/.owl/startup" file directly). As mentioned in the detailed documentation, the variable `zsig` takes precedence over `zsigproc`. Make sure that `zsig` is empty. Then set `zsigproc` to your random zsig generator program's location.
+1. Use the `:startup` command in Barnowl to write to the "~/.owl/startup" file (or wherever you decided to put the your startup settings file for Barnowl). (Alternatively, edit the "~/.owl/startup" file directly). As mentioned in the detailed documentation, the variable `zsig` takes precedence over `zsigproc`. Make sure that `zsig` is empty. Then set `zsigproc` to run our bit of bash magic.
 
                :startup set zsig ''
-               :startup set zsigproc '~/.zrandom']
+               :startup set zsigproc 'shuf -n1 ~/.zsigs'
        
 2. Force Barnowl to reload the startup configuration file