Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #201625 > unrolled thread

a quick tip that sometimes saves a lot of further worries

Started bysongbird <songbird@anthive.com>
First post2018-10-25 18:10 +0200
Last post2018-10-26 00:00 +0200
Articles 8 — 4 participants

Back to article view | Back to linux.debian.user


Contents

  a quick tip that sometimes saves a lot of further worries songbird <songbird@anthive.com> - 2018-10-25 18:10 +0200
    Re: a quick tip that sometimes saves a lot of further worries Nicholas Geovanis <nickgeovanis@gmail.com> - 2018-10-25 21:20 +0200
      Re: a quick tip that sometimes saves a lot of further worries Étienne Mollier <etienne.mollier@mailoo.org> - 2018-10-25 21:30 +0200
        Re: a quick tip that sometimes saves a lot of further worries Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-25 21:40 +0200
          Re: a quick tip that sometimes saves a lot of further worries Étienne Mollier <etienne.mollier@mailoo.org> - 2018-10-25 21:50 +0200
          Re: a quick tip that sometimes saves a lot of further worries songbird <songbird@anthive.com> - 2018-10-26 05:10 +0200
        Re: a quick tip that sometimes saves a lot of further worries songbird <songbird@anthive.com> - 2018-10-26 05:10 +0200
      Re: a quick tip that sometimes saves a lot of further worries songbird <songbird@anthive.com> - 2018-10-26 00:00 +0200

#201625 — a quick tip that sometimes saves a lot of further worries

Fromsongbird <songbird@anthive.com>
Date2018-10-25 18:10 +0200
Subjecta quick tip that sometimes saves a lot of further worries
Message-ID<wMQmR-11H-1@gated-at.bofh.it>
  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

[toc] | [next] | [standalone]


#201632

FromNicholas Geovanis <nickgeovanis@gmail.com>
Date2018-10-25 21:20 +0200
Message-ID<wMTkK-2JO-5@gated-at.bofh.it>
In reply to#201625
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 <songbird@anthive.com> 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
>

[toc] | [prev] | [next] | [standalone]


#201633

FromÉtienne Mollier <etienne.mollier@mailoo.org>
Date2018-10-25 21:30 +0200
Message-ID<wMTup-2MM-3@gated-at.bofh.it>
In reply to#201632
> On Thu, Oct 25, 2018 at 11:02 AM songbird <songbird@anthive.com> 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 <etienne.mollier@mailoo.org>

[toc] | [prev] | [next] | [standalone]


#201634

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-10-25 21:40 +0200
Message-ID<wMTE5-2PU-1@gated-at.bofh.it>
In reply to#201633
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.

[toc] | [prev] | [next] | [standalone]


#201635

FromÉtienne Mollier <etienne.mollier@mailoo.org>
Date2018-10-25 21:50 +0200
Message-ID<wMTNL-2Te-5@gated-at.bofh.it>
In reply to#201634

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 <etienne.mollier@mailoo.org>

[toc] | [prev] | [next] | [standalone]


#201655

Fromsongbird <songbird@anthive.com>
Date2018-10-26 05:10 +0200
Message-ID<wN0Fz-7dD-1@gated-at.bofh.it>
In reply to#201634
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

[toc] | [prev] | [next] | [standalone]


#201658

Fromsongbird <songbird@anthive.com>
Date2018-10-26 05:10 +0200
Message-ID<wN0FA-7dD-13@gated-at.bofh.it>
In reply to#201633
É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

[toc] | [prev] | [next] | [standalone]


#201651

Fromsongbird <songbird@anthive.com>
Date2018-10-26 00:00 +0200
Message-ID<wMVPA-45z-13@gated-at.bofh.it>
In reply to#201632
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web