a quick tip that sometimes saves a lot of further worries

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

a quick tip that sometimes saves a lot of further worries

songbird
  i'm sometimes developing code and in the process
manage to mess it up where it isn't backed up or
in any other spot, but i do have this habit of
keeping a terminal open with text and i sometimes
cat or scroll files there so as long as i don't
shut down the system i can go there and cut and
paste things.

  today this saved me a mild panic as i'd written
some code and then thought i'd copied it, but then
i'd clobbered that copy doing something else.

  *whew*

  and yes, i do make backups here or there, but
sometimes i work faster than i do that.  i also
use git, but i don't always stash temporary copies
all the time.  today i actually did make a temporary
copy, but that copy i clobbered on purpose and then
said "oops"  :)

  i started looking at undelete file utilities and
then said, hey perhaps i have this scrolled in
another terminal...

  now the really nice feature would be if i actually
made this into a system where my vi editor would
automagically scroll it for me in some window...
that will be for some other time.  i don't want to
get sidetracked any more for the moment.  gardens
are sidetracking me enough...

  just some thoughts in passing.  :)


  songbird

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

Nicholas Geovanis-2
Don't be afraid to use your backups (that you don't make.....)
I once restored most of a root filesystem I had deleted from a
running server. The server stayed up the whole time, through
the mess-up and the restore. Things like /lib.
DEC Alpha running OSF/1  :-)
And.....was OSF/1 ever open-sourced?

On Thu, Oct 25, 2018 at 11:02 AM songbird <[hidden email]> wrote:

>
>   i'm sometimes developing code and in the process
> manage to mess it up where it isn't backed up or
> in any other spot, but i do have this habit of
> keeping a terminal open with text and i sometimes
> cat or scroll files there so as long as i don't
> shut down the system i can go there and cut and
> paste things.
>
>   today this saved me a mild panic as i'd written
> some code and then thought i'd copied it, but then
> i'd clobbered that copy doing something else.
>
>   *whew*
>
>   and yes, i do make backups here or there, but
> sometimes i work faster than i do that.  i also
> use git, but i don't always stash temporary copies
> all the time.  today i actually did make a temporary
> copy, but that copy i clobbered on purpose and then
> said "oops"  :)
>
>   i started looking at undelete file utilities and
> then said, hey perhaps i have this scrolled in
> another terminal...
>
>   now the really nice feature would be if i actually
> made this into a system where my vi editor would
> automagically scroll it for me in some window...
> that will be for some other time.  i don't want to
> get sidetracked any more for the moment.  gardens
> are sidetracking me enough...
>
>   just some thoughts in passing.  :)
>
>
>   songbird
>

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

Étienne Mollier

> On Thu, Oct 25, 2018 at 11:02 AM songbird <[hidden email]> wrote:
>>   now the really nice feature would be if i actually
>> made this into a system where my vi editor would
>> automagically scroll it for me in some window...
>> that will be for some other time.  i don't want to
>> get sidetracked any more for the moment.  gardens
>> are sidetracking me enough...
>>

On 10/25/18 9:10 PM, Nicholas Geovanis wrote:
> Don't be afraid to use your backups (that you don't make.....)
> I once restored most of a root filesystem I had deleted from a
> running server. The server stayed up the whole time, through
> the mess-up and the restore. Things like /lib.
> DEC Alpha running OSF/1  :-)
> And.....was OSF/1 ever open-sourced?
>

Even though I kind of agree with Nicholas, your concept is quite
amusing.  :-)

Would that shell function do the kind of thing you would expect?

        vi () {
                local arg
                for arg in "$@"
                do
                        if [ -f "$arg" ]
                        then
                                printf '<<< %s >>>\n' "$arg"
                                cat "./$arg"
                        fi
                done
       
                command vi "$@"
       
                for arg in "$@"
                do
                        if [ -f "$arg" ]
                        then
                                printf '>>> %s <<<\n' "$arg"
                                cat "./$arg"
                        fi
                done
        }

Feel free to refine to your taste.
Kind Regards,
--
Étienne Mollier <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

Greg Wooledge
On Thu, Oct 25, 2018 at 09:21:27PM +0200, Étienne Mollier wrote:
> for arg in "$@"
> do
> if [ -f "$arg" ]
> then
> printf '<<< %s >>>\n' "$arg"
> cat "./$arg"

The ./ breaks the function if you give it absolute pathnames.  Replace
this last line with cat -- "$arg" instead.

A "clever" version of this part of the function that does something
similar in a more compact form is:

tail -n +1 -- "$@"

I didn't write that and can't claim credit for it, but I don't know who
did, so I can't give appropriate credit either.

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

Étienne Mollier


On 10/25/18 9:35 PM, Greg Wooledge wrote:
> On Thu, Oct 25, 2018 at 09:21:27PM +0200, Étienne Mollier wrote:
>> for arg in "$@"
>> do
>> if [ -f "$arg" ]
>> then
>> printf '<<< %s >>>\n' "$arg"
>> cat "./$arg"
> The ./ breaks the function if you give it absolute pathnames.  Replace
> this last line with cat -- "$arg" instead.

Whoopsie!  Indeed.
Got the brain messed with some ./--help file to remove, again...
And since some programs don't (didn't) implement "--", well the
broken solution went first...

> A "clever" version of this part of the function that does something
> similar in a more compact form is:
>
> tail -n +1 -- "$@"

That's neat!  :-D
It may spew a few errors if for some reason, options are passed to
the editor, and is a little less flexible if we want to add, say
date information, nevertheless cool!

> I didn't write that and can't claim credit for it, but I don't know who
> did, so I can't give appropriate credit either.

I suppose those gentlemen can earn a bit of credit for having
implemented it in "tail" in the first place then, if I trust the
manual:
> AUTHOR
>        Written by Paul Rubin, David MacKenzie, Ian  Lance  Tay‐
>        lor, and Jim Meyering.

Kind Regards,
--
Étienne Mollier <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

songbird
In reply to this post by Nicholas Geovanis-2
Nicholas Geovanis wrote:
> Don't be afraid to use your backups (that you don't make.....)

  heh, well i did make one and i also did a push to
my other repository so at least now i have that code
elsewhere safe.


> I once restored most of a root filesystem I had deleted from a
> running server. The server stayed up the whole time, through
> the mess-up and the restore. Things like /lib.
> DEC Alpha running OSF/1  :-)

  rm -rf is dangerous to type in the wrong window.  i've gotten
in the habit of specifying at least part of the path now to
avoid the worst of the typos that can be made...


> And.....was OSF/1 ever open-sourced?

  i thought everyone was running Plan 9...


  songbird

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

songbird
In reply to this post by Étienne Mollier
Étienne Mollier wrote:
...
> Even though I kind of agree with Nicholas, your concept is quite
> amusing.  :-)

  :)  what good is having multiple terminal windows if you
don't use them?  most of the time i use only four of them per
project.


> Would that shell function do the kind of thing you would expect?
>
> vi () {
> local arg
> for arg in "$@"
> do
> if [ -f "$arg" ]
> then
> printf '<<< %s >>>\n' "$arg"
> cat "./$arg"
> fi
> done
>
> command vi "$@"
>
> for arg in "$@"
> do
> if [ -f "$arg" ]
> then
> printf '>>> %s <<<\n' "$arg"
> cat "./$arg"
> fi
> done
> }
>
> Feel free to refine to your taste.
> Kind Regards,

charge!

  now here's the fun, multiple terminal windows open and i only
want a certain one to be used but with booting i cannot be
certain which ones are which.  :(

  may have to explore udev more.  the above script and modifications
are noted for future reference...  ;)  tks.  lol

  p.s. there is this thing called bup which i've installed and
used before, i'm sure it could be setup and fired off about every
few minutes to capture finer detail slices than what my current
backups are doing.

  i'll be pondering all of this some time in the future...  but
not tonight.  cheers,


  songbird

Reply | Threaded
Open this post in threaded view
|

Re: a quick tip that sometimes saves a lot of further worries

songbird
In reply to this post by Greg Wooledge
Greg Wooledge wrote:
...

> The ./ breaks the function if you give it absolute pathnames.  Replace
> this last line with cat -- "$arg" instead.
>
> A "clever" version of this part of the function that does something
> similar in a more compact form is:
>
> tail -n +1 -- "$@"
>
> I didn't write that and can't claim credit for it, but I don't know who
> did, so I can't give appropriate credit either.

  we all can be clever in different ways.  :)

  i'm usually pretty good at doing things oddly enough
that i make a good test subject.

  tks, i'll stash this reply too...


  songbird