asg@sage.cc.purdue.edu (Bruce Varney) (04/06/91)
In article <SQUASH.91Apr4184954@heat.math.ufl.edu> squash@math.ufl.edu (Jonathan King) writes: }Could some kind soul tell me how to write an alias (or a script) }which, after having done something (eg. an lpr command) }places on the history list, a particular command. } My intention is to later execute this command with !! . } If this cannot be done, is it possible to have the alias type a }command to the Unix prompt, so that I can hit <CR> later to execute it? } }Jonathan squash@math.ufl.edu I believe ksh can do it print -s whateveryouwantaddedtoyourhistorylist hope this helps Bruce --------- sar.casm \'sa:r-.kaz-*m\ \sa:r-'kas-tik\ \-ti-k(*-)le-\ n [F sarcasme, fr. LL sarcasmos, fr. Gk sarkasmos, fr. sarkazein to tear flesh, bite the lips in rage, sneer, fr. sark-, sarx flesh; akin to Av thwar*s to cut] 1: a cutting, hostile, or contemptuous remark : GIBE 2: the use of caustic or ironic language - sar.cas.tic aj ### ## Courtesy of Bruce Varney ### # aka -> The Grand Master # asg@sage.cc.purdue.edu ### ##### # PUCC ### # ;-) # # ;'> # ##
weimer@garden.ssd.kodak.com (Gary Weimer (253-7796)) (04/06/91)
In article <SQUASH.91Apr4184954@heat.math.ufl.edu> you write: |> Could some kind soul tell me how to write an alias (or a script) |> which, after having done something (eg. an lpr command) |> places on the history list, a particular command. |> My intention is to later execute this command with !! . |> If this cannot be done, is it possible to have the alias type a |> command to the Unix prompt, so that I can hit <CR> later to execute it? Not exactly what you asked, but in csh you could just do: alias cmd 'FIRST_THING;echo "SECOND_THING";set x=$<;SECOND_THING' this will run FIRST_THING, print SECOND_THING (not at a prompt), wait for <CR> and then run SECOND_THING weimer@ssd.kodak.com ( Gary Weimer )
rhartman@thestepchild.sgi.com (Robert Hartman) (04/09/91)
In article <1991Apr5.184054.20966@ssd.kodak.com> weimer@ssd.kodak.com writes: > >In article <SQUASH.91Apr4184954@heat.math.ufl.edu> you write: >|> Could some kind soul tell me how to write an alias (or a script) >|> which, after having done something (eg. an lpr command) >|> places on the history list, a particular command. >|> My intention is to later execute this command with !! . >|> If this cannot be done, is it possible to have the alias type a >|> command to the Unix prompt, so that I can hit <CR> later to execute it? > >Not exactly what you asked, but in csh you could just do: > >alias cmd 'FIRST_THING;echo "SECOND_THING";set x=$<;SECOND_THING' > >this will run FIRST_THING, print SECOND_THING (not at a prompt), >wait for <CR> and then run SECOND_THING > >weimer@ssd.kodak.com ( Gary Weimer ) Rather than put it on the history list or in a variable, you could have your alias create a new alias for you. For instance, I use the following alias for cd: alias cd 'set pd=$cwd;chdir \!*;alias $cwd:t "cd $cwd";echo $cwd;u $ulist' This does, in order: saves the pathname of the current (soon to be previous) directory in $pd changes directory creates an alias using the basename of the new directory as the name; when I want to cd to that directory again in future, I can just invoke its basename as a command echoes the pathname of the new directory unaliases directory names that are also names of commands, such as "man" and "sccs" BTW, here are some of my other "navigational" aliases: alias pd 'set qd=$cwd;chdir $pd;set pd=$qd;echo $cwd' alias . 'echo $cwd' alias .. 'cd ..' alias , pd The aliasing scheme in csh accepts "." characters. Not so with ksh, so the equivalent trick is a little more complicated. Last time I did it, I had to use a shell procedure named CD for the guts of the thing. BTW, I was also able to give myself a directory history in sh using a shell procedure that creates new ones. -r
jensen@diku.dk (J|rgen Jensen) (04/15/91)
(I've directed followups to comp.unix.questions.) asg@sage.cc.purdue.edu (Bruce Varney) writes: >In article <SQUASH.91Apr4184954@heat.math.ufl.edu> squash@math.ufl.edu (Jonathan King) writes: >}Could some kind soul tell me how to write an alias (or a script) >}which, after having done something (eg. an lpr command) >}places on the history list, a particular command. >} My intention is to later execute this command with !! . >} If this cannot be done, is it possible to have the alias type a >}command to the Unix prompt, so that I can hit <CR> later to execute it? >} >}Jonathan squash@math.ufl.edu >I believe ksh can do it >print -s whateveryouwantaddedtoyourhistorylist >hope this helps > Bruce In a non-wimpy csh: alias youralias 'yourcmd; echo yournextcmd > tmpfile; source -h tmpfile' -- . . . . . . . . . . . . . . . . . . . . . . . . . . j e n s e n (jensen@diku.dk) Opinions? -- These are rock-solid facts!