Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
bash typewriter simulator
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
chipschap  
View profile  
 More options Nov 24 2011, 2:01 pm
Newsgroups: comp.unix.shell
From: chipschap <chipsc...@gmail.com>
Date: Thu, 24 Nov 2011 11:01:36 -0800 (PST)
Local: Thurs, Nov 24 2011 2:01 pm
Subject: bash typewriter simulator
For all of you creative writers out there who like minimalist
environments, here is a bash typewriter simulator. No arrow keys,
backspacing, cut and paste, nothing. What you type is what you get and
you better get it right the first time. Some writers think this helps
them focus and think about what they're writing instead of just typing
any old thing. Other writers say it makes them faster because they
can't back up and edit, they just have to keep typing. Whatever.

The script is posted below. Updates (if any, hah), and a clean version
without potential superfluous line wraps caused by posting, appear at

http://www.bobnewell.net/filez/bashwriter

############################ begin bashwriter
#############################
#!/bin/bash

# Bash typewriter simulator.

# Runs on any relatively recent Linux system.
# Not tested on anything else.

# This is a 'pure typing' environment. Like a typewriter,
# you can't backspace, can't edit, can only type. This is
# supposed to increase creative writing quality and output,
# though your mileage definitely may vary. The ideas are that

# (1) you have no choice but to keep typing and
# (2) you type less junk when you know you can't erase it.

# That's the theory, anyhow. But the fact is that this is a
# dead simple typing environment (it's certainly not an editor
# as such) that will run on just about any modern Linux system.

# Usage: bashwriter filename

# 'filename' is the input/output file and is required.
# The program is exited by pressing ctrl-C or ctrl-Z.

# Typing: this is like a typewriter. You have to do a carriage
# return at the end of a line. A real typewriter has a backspace
# key, tab key, etc., but this one doesn't because we can't simulate
# overstrikes on a terminal and we don't want to bother with coding
# stuff like tab settings.

# Additional features are not anticipated; they would not be in
# keeping with this bare minimalist approach. So no typing sounds,
# color changes, choice of fonts, etc. You can do some of that stuff
# by setting up a bash profile. Call it a 'typing' profile if you
# want and put a command on your menu to call this program with that
# profile. Black type on a creamy white background and a fixed-width
# typewriter font would be in keeping with the theme.

# If you are foolish enough to think this script is any good,
# consider the fact that another fellow wrote an excellent typewriter
# simulator in about 20 lines of HTML. Now *that* is good!

# Comments, bugs, changes to: bashwri...@bobnewell.net
# Note that this is not a promise of performance.

# The script is Copyright (C) 2011 by Futrezo Software Systems, a
division
# of Mr. Fred Investments. A free, unlimited, non-exclusive license
# to use the script in any legal manner is granted. You may use it,
# change it, create derivative works, sell it, give it away, or do
# anything you like as long as it is lawful, but you may not take
# ownership of the original script from us.

# No warranties are provided, nor is any form of liability accepted.
# No support is offered or provided.

# 2011/11/24 0.02 Thanksgiving Day release.
#                 Cleaned up a few things.
#                 Probably as 'final' as it's going to get.
#                 (Famous last words.)
# 2011/11/23 0.01 Bob Newell, Honolulu, Hawai`i.
#                 Initial coding.

function fish {
# Program termination function, as in 'go fish'.
        IFS=$saveifs
        reset
        exit 0

}

version="0.02 of 24 Nov 2011"

saveifs=$IFS
IFS=""

# The size of the preserved text on the screen. This helps
# mimic typewriter-like scrolling up. Right now it's hardwired.
# It should really be based on the screen height but $LINES doesn't
# seem to work within a bash script.

tailsize=10

tfile=$1

echo "BASHWRITER typewriter simulator, version $version."

# Test for specification of file.
if [[ "$tfile" == "" ]]
then
        echo "No typewriter file specified."
        exit 1
fi

# Test existence of file. If not, try to create.
if [[ ! -f "$tfile" ]]
then
        touch "$tfile" 2>/dev/null
        if [[ $? -ne 0 ]]
        then
                echo "Cannot create typewriter file $tfile."
                exit 1
        fi
fi

# See if the file is writable.
if [[ ! -w "$tfile" ]]
then
        echo "Typewriter file $tfile cannot be opened for writing."
        exit 1
fi

# Clear screen and put initial lines up.
clear
tail -$tailsize $tfile 2>/dev/null

# Traps follow. 'fish' is a closeout routine which resets
# the console, etc.

trap fish QUIT
trap fish INT
trap fish HUP
trap fish TSTP

C=""

# Remember: we have to ctrl-C out of the program.

while [[ 1 -eq 1 ]];
do

# Read one character at a time, no escape sequences, no screen echo.

        read -n 1 -s -r C
        if [[ $C != "" ]]
        then

# Process anything but carriage return, which comes through as "".
# Then test printable, ignore if not. This gets rid of backspace etc.
# If the char is usable, echo to the file and to the screen.
# This requires POSIX which any relatively recent Linux system will
have.

                if [[ $C == [[:print:]] ]]
                then
                        echo -n $C >>$tfile
                        echo -n $C
                fi
        else

# Carriage return was evidently typed, triggering a scroll up.

                echo "" >>$tfile
                clear
                tail -$tailsize $tfile
        fi
done

############################# end bashwriter #########################


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakrichev...@gmail.com  
View profile  
 More options Oct 10 2012, 9:30 pm
Newsgroups: comp.unix.shell
From: bakrichev...@gmail.com
Date: Wed, 10 Oct 2012 18:30:11 -0700 (PDT)
Local: Wed, Oct 10 2012 9:30 pm
Subject: Re: bash typewriter simulator

how do i d.l?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris F.A. Johnson  
View profile  
 More options Oct 10 2012, 10:03 pm
Newsgroups: comp.unix.shell
From: "Chris F.A. Johnson" <cfajohn...@gmail.com>
Date: Wed, 10 Oct 2012 21:58:32 -0400
Local: Wed, Oct 10 2012 9:58 pm
Subject: Re: bash typewriter simulator

On 2012-10-11, bakrichev...@gmail.com wrote:
> On Thursday, November 24, 2011 2:01:36 PM UTC-5, chipschap wrote:
...
>> http://www.bobnewell.net/filez/bashwriter
...
> how do i d.l?

wget http://www.bobnewell.net/filez/bashwriter

--
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kaz Kylheku  
View profile  
 More options Oct 10 2012, 11:32 pm
Newsgroups: comp.unix.shell
From: Kaz Kylheku <k...@kylheku.com>
Date: Thu, 11 Oct 2012 03:32:20 +0000 (UTC)
Local: Wed, Oct 10 2012 11:32 pm
Subject: Re: bash typewriter simulator
On 2012-10-11, Chris F.A. Johnson <cfajohn...@gmail.com> wrote:

> On 2012-10-11, bakrichev...@gmail.com wrote:
>> On Thursday, November 24, 2011 2:01:36 PM UTC-5, chipschap wrote:
> ...
>>> http://www.bobnewell.net/filez/bashwriter
> ...
>> how do i d.l?

> wget http://www.bobnewell.net/filez/bashwriter

Bah,

http://git.savannah.gnu.org/cgit/bash.git/tree/examples/scripts/line-...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris F.A. Johnson  
View profile  
 More options Oct 11 2012, 12:18 am
Newsgroups: comp.unix.shell
From: "Chris F.A. Johnson" <cfajohn...@gmail.com>
Date: Thu, 11 Oct 2012 00:06:27 -0400
Local: Thurs, Oct 11 2012 12:06 am
Subject: Re: bash typewriter simulator
On 2012-10-11, Kaz Kylheku wrote:

> On 2012-10-11, Chris F.A. Johnson <cfajohn...@gmail.com> wrote:
>> On 2012-10-11, bakrichev...@gmail.com wrote:
>>> On Thursday, November 24, 2011 2:01:36 PM UTC-5, chipschap wrote:
>> ...
>>>> http://www.bobnewell.net/filez/bashwriter
>> ...
>>> how do i d.l?

>> wget http://www.bobnewell.net/filez/bashwriter

> Bah,

> http://git.savannah.gnu.org/cgit/bash.git/tree/examples/scripts/line-...

   The original script was designed to be a "typewriter" that accepted no
   editing. That needs nothing more than:

printf "Enter file name: "
read file
echo "Press ^D to quit"
cat > "$file"

--
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron W. Hsu  
View profile  
 More options Oct 11 2012, 2:06 pm
Newsgroups: comp.unix.shell
From: "Aaron W. Hsu" <arcf...@sacrideo.us>
Date: Thu, 11 Oct 2012 14:06:40 -0400
Local: Thurs, Oct 11 2012 2:06 pm
Subject: Re: bash typewriter simulator
On Thu, 11 Oct 2012 00:06:27 -0400, Chris F.A. Johnson  

<cfajohn...@gmail.com> wrote:
>    The original script was designed to be a "typewriter" that accepted no
>    editing. That needs nothing more than:

> printf "Enter file name: "
> read file
> echo "Press ^D to quit"
> cat > "$file"

On most systems, that will still allow for line editing, unless you  
explicitly disable it.

--
Aaron W. Hsu | arcf...@sacrideo.us | http://www.sacrideo.us
Programming is just another word for the Lost Art of Thinking.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris F.A. Johnson  
View profile  
 More options Oct 11 2012, 6:18 pm
Newsgroups: comp.unix.shell
From: "Chris F.A. Johnson" <cfajohn...@gmail.com>
Date: Thu, 11 Oct 2012 18:10:11 -0400
Local: Thurs, Oct 11 2012 6:10 pm
Subject: Re: bash typewriter simulator
On 2012-10-11, Aaron W. Hsu wrote:

> On Thu, 11 Oct 2012 00:06:27 -0400, Chris F.A. Johnson  
><cfajohn...@gmail.com> wrote:

>>    The original script was designed to be a "typewriter" that accepted no
>>    editing. That needs nothing more than:

>> printf "Enter file name: "
>> read file
>> echo "Press ^D to quit"
>> cat > "$file"

> On most systems, that will still allow for line editing, unless you  
> explicitly disable it.

   I haven't seen a system where it allows any editing other than backspacing
   and deleting the previous character.

   This bash script allows more line editing:

printf "Enter file name: "
read file
echo "Press ^D to quit"
while IFS= read -rep ''
do
  printf "%s\n" "$REPLY"
done > "$file"

--
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kaz Kylheku  
View profile  
 More options Oct 11 2012, 6:57 pm
Newsgroups: comp.unix.shell
From: Kaz Kylheku <k...@kylheku.com>
Date: Thu, 11 Oct 2012 22:57:31 +0000 (UTC)
Local: Thurs, Oct 11 2012 6:57 pm
Subject: Re: bash typewriter simulator
On 2012-10-11, Chris F.A. Johnson <cfajohn...@gmail.com> wrote:

Right, erasing and retyping are not the *true* Scotsman's editing features.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Bacarisse  
View profile  
 More options Oct 11 2012, 8:48 pm
Newsgroups: comp.unix.shell
From: Ben Bacarisse <ben.use...@bsb.me.uk>
Date: Fri, 12 Oct 2012 01:48:48 +0100
Local: Thurs, Oct 11 2012 8:48 pm
Subject: Re: bash typewriter simulator
"Chris F.A. Johnson" <cfajohn...@gmail.com> writes:

My Linux system also allows me to erase a word and to kill the whole
line.

<snip>
--
Ben.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris F.A. Johnson  
View profile  
 More options Oct 11 2012, 10:03 pm
Newsgroups: comp.unix.shell
From: "Chris F.A. Johnson" <cfajohn...@gmail.com>
Date: Thu, 11 Oct 2012 21:59:29 -0400
Local: Thurs, Oct 11 2012 9:59 pm
Subject: Re: bash typewriter simulator
On 2012-10-12, Ben Bacarisse wrote:

   So it does. But it will only delete to the left, and one cannot move the
   cursor over the line as you can with read -e.

--
   Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
   ===================================================================
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron W. Hsu  
View profile  
 More options Oct 12 2012, 3:57 am
Newsgroups: comp.unix.shell
From: "Aaron W. Hsu" <arcf...@sacrideo.us>
Date: Fri, 12 Oct 2012 03:57:20 -0400
Local: Fri, Oct 12 2012 3:57 am
Subject: Re: bash typewriter simulator
On Thu, 11 Oct 2012 21:59:29 -0400, Chris F.A. Johnson  

I think part of the point of the original script was to simulate a  
typewriter. One of the main points about a typewriter in that script is  
that you cannot do *any* editing. Being able to erase characters defeats  
the simulation. The simulator is supposed to be just like typing directly  
onto the paper.

--
Aaron W. Hsu | arcf...@sacrideo.us | http://www.sacrideo.us
Programming is just another word for the Lost Art of Thinking.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Margolin  
View profile  
 More options Oct 12 2012, 10:40 am
Newsgroups: comp.unix.shell
From: Barry Margolin <bar...@alum.mit.edu>
Date: Fri, 12 Oct 2012 10:40:49 -0400
Local: Fri, Oct 12 2012 10:40 am
Subject: Re: bash typewriter simulator
In article <op.wl121usr0p3ku8@localhost>,
 "Aaron W. Hsu" <arcf...@sacrideo.us> wrote:

It's been a while, but I think the last typewriter I used had an
automatic white-out feature that could be used to delete individual
characters backwards.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron W. Hsu  
View profile  
 More options Oct 12 2012, 3:31 pm
Newsgroups: comp.unix.shell
From: "Aaron W. Hsu" <arcf...@sacrideo.us>
Date: Fri, 12 Oct 2012 15:31:49 -0400
Local: Fri, Oct 12 2012 3:31 pm
Subject: Re: bash typewriter simulator
On Fri, 12 Oct 2012 10:40:49 -0400, Barry Margolin <bar...@alum.mit.edu>  
wrote:

> It's been a while, but I think the last typewriter I used had an
> automatic white-out feature that could be used to delete individual
> characters backwards.

I always considered that cheating. :-) Mostly, the only typewriters that  
have really interested me were the Selectric (for the novel type-ball) and  
the purely mechanical ones. Did any of the pure mechanical ones have a  
ribbon for white-out? I guess the UNIX line editing features would sort of  
constitute the white-out feature, but the ^W and ^U still do a little more  
than that.

--
Aaron W. Hsu | arcf...@sacrideo.us | http://www.sacrideo.us
Programming is just another word for the Lost Art of Thinking.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
giacomo boffi  
View profile  
 More options Oct 13 2012, 1:11 pm
Newsgroups: comp.unix.shell
From: giacomo boffi <pec...@pascolo.net>
Date: Sat, 13 Oct 2012 19:11:17 +0200
Local: Sat, Oct 13 2012 1:11 pm
Subject: Re: bash typewriter simulator
"Aaron W. Hsu" <arcf...@sacrideo.us> writes:

> I think part of the point of the original script was to simulate a
> typewriter. One of the main points about a typewriter in that script
> is  that you cannot do *any* editing. Being able to erase characters
> defeats  the simulation. The simulator is supposed to be just like
> typing directly  onto the paper.

The simulator is supposed to be just like

<creepy music> punching holes in a card. </creepy music>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Combs  
View profile  
 More options Dec 7 2012, 7:13 pm
Newsgroups: comp.unix.shell
From: dkco...@panix.com (David Combs)
Date: Sat, 8 Dec 2012 00:13:20 +0000 (UTC)
Local: Fri, Dec 7 2012 7:13 pm
Subject: Re: bash typewriter simulator
In article <op.wl2y7bwz0p3ku8@localhost>,
Aaron W. Hsu <arcf...@sacrideo.us> wrote:

>On Fri, 12 Oct 2012 10:40:49 -0400, Barry Margolin <bar...@alum.mit.edu>  
>wrote:

>> It's been a while, but I think the last typewriter I used had an
>> automatic white-out feature that could be used to delete individual
>> characters backwards.

>I always considered that cheating. :-) Mostly, the only typewriters that  
>have really interested me were the Selectric (for the novel type-ball) and  
>the purely mechanical ones. Did any of the pure mechanical ones have a  
>ribbon for white-out?

Yes, I remember a wee reel of IBM white-out tape that fit on a selectric.
And on hitting a certain key (I don't recall which), the white-out tape
would pop up in front of the ink-tape (which itself was between the ball
and the paper, of course.)

But that's just my memory; I could be wrong.

I do recall saying, when the conversation got to IBM computers and especially
OSes such as TSO and VM/CMS, that well, they sure made good typewriters! (if
nothing else).

I guess the UNIX line editing features would sort of  

>constitute the white-out feature, but the ^W and ^U still do a little more  
>than that.

>--
>Aaron W. Hsu | arcf...@sacrideo.us | http://www.sacrideo.us
>Programming is just another word for the Lost Art of Thinking.

David

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon LaBadie  
View profile  
 More options Dec 8 2012, 6:51 pm
Newsgroups: comp.unix.shell
From: Jon LaBadie <jlaba...@aXcXm.org>
Date: Sat, 08 Dec 2012 18:51:44 -0500
Local: Sat, Dec 8 2012 6:51 pm
Subject: Re: bash typewriter simulator
On 12/07/2012 07:13 PM, David Combs wrote:

My memory differs slightly.  The IBM Selectric didn't us an "inked ribbon"
but a clear film coated with fine black powder.  The impact left the carbon
on the surface of the paper rather than being absorbed into the fibers.

The erase tape was not "white out" but a film coated with adhesive.  When
it was struck, it picked up the black powder from the surface of the paper.
It didn't cover it up the way "white out" would, but actually removed it.

jl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »