From: no.top.post on
I want to be able to:
* call the script: boj
* which then shows it's can-do-menu
* initially say -
1= append to my [probably 1 per line] known phrases;
perhaps the lines are just appended below the code's 'exit'.
2= show my list of known phrases,
2a= and accept an index or a 'key' to return the selected 1-line-known-phrase.

The hope is that my existing utilities which can call shell, would be able to
go off and store eg. path/FileIDs and fetch a phrase, eg. for execution.

How would I start coding this?

==TIA.

PS.an application for me is mc's cedit's ability to select-constructs that
apply the the specific language of the file being edited -- probably vim
and emacs can do this too. So now I want to:
V: enter new IDs or fetch existing IDs.
-Enter name of new ID - perhaps show alfa-sorted existing IDs,
to avoid using an existing ID?
-Select one of existing IDs, to be printed at the cursor.
[like the selected construct-skeletons are preinted at the cursor].



From: goarilla on
On Fri, 01 Jan 2010 17:08:30 +0000, no.top.post wrote:

> I want to be able to:
> * call the script: boj
> * which then shows it's can-do-menu
> * initially say -
> 1= append to my [probably 1 per line] known phrases;
> perhaps the lines are just appended below the code's 'exit'.
> 2= show my list of known phrases,
> 2a= and accept an index or a 'key' to return the selected
> 1-line-known-phrase.
>
> The hope is that my existing utilities which can call shell, would be
> able to go off and store eg. path/FileIDs and fetch a phrase, eg. for
> execution.
>
> How would I start coding this?
>
> ==TIA.
>
> PS.an application for me is mc's cedit's ability to select-constructs
> that
> apply the the specific language of the file being edited -- probably
> vim
> and emacs can do this too. So now I want to:
> V: enter new IDs or fetch existing IDs. -Enter name of new ID - perhaps
> show alfa-sorted existing IDs,
> to avoid using an existing ID?
> -Select one of existing IDs, to be printed at the cursor.
> [like the selected construct-skeletons are preinted at the cursor].

you're not making any sense
From: Bit Twister on
["Followup-To:" header set to comp.os.linux.misc.]
On Fri, 1 Jan 2010 17:08:30 +0000 (UTC), no.top.post(a)gmail.com wrote:
> I want to be able to:
> * call the script: boj
> * which then shows it's can-do-menu
> * initially say -
> 1= append to my [probably 1 per line] known phrases;
> perhaps the lines are just appended below the code's 'exit'.
> 2= show my list of known phrases,
> 2a= and accept an index or a 'key' to return the selected 1-line-known-phrase.
>
> The hope is that my existing utilities which can call shell, would be able to
> go off and store eg. path/FileIDs and fetch a phrase, eg. for execution.
>
> How would I start coding this?

My recommendation would be to put your phrases in a file like boj.data

That file could be an array of phrases.

Your other apps call boj which loads/displays boj.array. User picks a
selection and boj can pass the phrase id or phrase back however you
like.

Design is up to you. boj could be a program/app or just a bunch of
functions to manage boj.data.

1. Your existing utilities call boj with command/arguments or
2. you script boj commands in your utilities by sourcing functions
found int boj.


Example 1: _result=$(boj get_phrase)
boj add_phrase "whatever"

Example 2: . boj # source boj functions/code
_result=get_phrase()
add_phrase "whatever"

Some light reading found at http://tldp.org/LDP/abs/html/index.html
From: Joseph Rosevear on
In alt.os.linux.slackware no.top.post(a)gmail.com wrote:
> I want to be able to:
> * call the script: boj
> * which then shows it's can-do-menu
> * initially say -
> 1= append to my [probably 1 per line] known phrases;
> perhaps the lines are just appended below the code's 'exit'.
> 2= show my list of known phrases,
> 2a= and accept an index or a 'key' to return the selected 1-line-known-phrase.

> The hope is that my existing utilities which can call shell, would be able to
> go off and store eg. path/FileIDs and fetch a phrase, eg. for execution.

> How would I start coding this?

Well. This sounds like an old problem that is close to my heart.
There are a lot of phrases to remember when you use Linux (or any
*nix). If you just had a way to code them and retrieve them for use
later, then just think what you could do? The code would serve to
document the phrases as well as to make them available. Perhaps your
"2= show my list of known phrases" could also give a little information
about how to use them.

What I do is similar, but I use a Bash script or function for each
phrase. The script lets the phrase be of general use, because in it I
can use positional paramers (like $1). For example, lets say the
phrase is "cp ~/file.dat /tmp". I don't know why you would do that,
but you might. It copies file "file.dat" from your home dir to the tmp
dir.

Here is a script that does the same thing, but is general purpose:

#####################################

#!/bin/sh

cp ~/$1 /tmp

#####################################

If you give the script a name like

cp2tmp

and put it in a dir that is in your PATH, say maybe

/usr/local/bin

then your command cp2tmp will always be available.

Do this with other phrases too. Make them into scripts and put them in
/usr/local/bin. After a while you'll have a very useful set of tools
that also documents the phrases that you've learned. After this set of
tools grows a bit you'll want to make a tool, call it "menu", that
lists your tools. Put it in /usr/local/bin also. Here is "menu":

#####################################

#!/bin/sh

cat << DONE

Tool Description
---- -----------
cp2tmp Uses cp to copy \$1 to /tmp
tool2 Does this
tool3 Does that
.. .
.. .
.. .

DONE

#######################################

What I do (I call it SAM) is a little like the examples above. Maybe
I've given you some ideas that you can use?

-Joe
From: Chris F.A. Johnson on
On 2010-01-01, Joseph Rosevear wrote:
> In alt.os.linux.slackware no.top.post(a)gmail.com wrote:
>> I want to be able to:
>> * call the script: boj
>> * which then shows it's can-do-menu
>> * initially say -
>> 1= append to my [probably 1 per line] known phrases;
>> perhaps the lines are just appended below the code's 'exit'.
>> 2= show my list of known phrases,
>> 2a= and accept an index or a 'key' to return the selected 1-line-known-phrase.
>
>> The hope is that my existing utilities which can call shell, would be able to
>> go off and store eg. path/FileIDs and fetch a phrase, eg. for execution.
>
>> How would I start coding this?
>
> Well. This sounds like an old problem that is close to my heart.
> There are a lot of phrases to remember when you use Linux (or any
> *nix). If you just had a way to code them and retrieve them for use
> later, then just think what you could do? The code would serve to
> document the phrases as well as to make them available. Perhaps your
> "2= show my list of known phrases" could also give a little information
> about how to use them.
>
> What I do is similar, but I use a Bash script or function for each
> phrase. The script lets the phrase be of general use, because in it I
> can use positional paramers (like $1). For example, lets say the
> phrase is "cp ~/file.dat /tmp". I don't know why you would do that,
> but you might. It copies file "file.dat" from your home dir to the tmp
> dir.
>
> Here is a script that does the same thing, but is general purpose:

Not general enough; it will fail if $1 contains whitespace.

> #####################################
>
> #!/bin/sh
>
> cp ~/$1 /tmp

cp ~/"$1" /tmp

Better still might be:

cp "$1" /tmp

> #####################################

--
Chris F.A. Johnson, author | <http://cfajohnson.com>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence