Getting a command to move to the time machine backup of working dir

2017-09-25 Thread Michael
So I'm trying to figure out a good alias command to move to the backup of the 
current dir.

 pushd "$(tmutil latestbackup)"/"$(pwd -P)"
-bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
Pro/2017-09-25-072130//Volumes/UserData/Users/michael/Movies/Episode projects 
and notes/Corona Trials: No such file or directory
keybounceMBP:Corona Trials michael$ 

The issue? Root will be missing the  name of root; all other partitions will 
have a "/Volumes" in the middle that needs to be removed.

Does anyone have a good way to say "Get me to the backup of the current 
directory", for a pushd target?


---
Entertaining minecraft videos
http://YouTube.com/keybounce

___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-26 Thread @lbutlr
On Sep 25, 2017, at 10:22 AM, Michael  wrote:
> pushd "$(tmutil latestbackup)"/"$(pwd -P)"

pushd "$(tmutil latestbackup)"/"$(pwd -P)" is better because there is no double 
slash in the path.

But that still doesn't solve the root name of the machine.

The machine name is in /Volumes/ as a link (everything else there is a folder).

ls -d `find /Volumes/ -maxdepth 1 -type l -print` | sed 's/\/Volumes\///'

This seems to work:

pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l 
-print` | sed 's/\/Volumes\///')$(pwd -P)"

$ pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l 
-print` | sed 's/\/Volumes\///')$(pwd -P)"
/Volumes/Tardis/Backups.backupdb/jaka/2017-09-26-075907/Jaka/Applications 
/Applications ~
jaka:Applications lbutlr$ pwd
/Volumes/Tardis/Backups.backupdb/jaka/2017-09-26-075907/Jaka/Applications

But there is probably a better way

-- 
Apple broke AppleScripting signatures in Mail.app, so no random signatures.

___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-26 Thread @lbutlr
On Sep 26, 2017, at 8:44 AM, @lbutlr  wrote:
> pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l 
> -print` | sed 's/\/Volumes\///')$(pwd -P)"

AFAIC, this works and is shorter, but I don't use pushd myself:

pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l` | sed 
's/\/Volumes\///')"

-- 
Apple broke AppleScripting signatures in Mail.app, so no random signatures.

___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-26 Thread Michael

On 2017-09-26, at 7:50 AM, @lbutlr  wrote:

> On Sep 26, 2017, at 8:44 AM, @lbutlr  wrote:
>> pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l 
>> -print` | sed 's/\/Volumes\///')$(pwd -P)"
> 
> AFAIC, this works and is shorter, but I don't use pushd myself:
> 
> pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l` | 
> sed 's/\/Volumes\///')"

Lacking the current directory at the end, it can't work.

The longer one?
keybounceMBP:Library michael$ pushd "$(tmutil latestbackup)$(ls -d `find 
/Volumes/ -maxdepth 1 -ty
pe l -print` | sed 's/\/Volumes\///')$(pwd -P)"
ls: cannot access '/Volumes//New': No such file or directory
ls: cannot access 'Main': No such file or directory
-bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
Pro/2017-09-26-184525/Users/michael/Library: No such file or directory

... Yea, my root volume has a space in the name "New Main".

So how badly  can I nest "$( ?

keybounceMBP:Library michael$ pushd "$(tmutil latestbackup)""$(ls -d "$(find 
/Volumes/ -maxdepth 1
 -type l -print) | sed 's/\/Volumes\///')""$(pwd -P)"
> 

Missed one, try again

keybounceMBP:Library michael$ pushd "$(tmutil latestbackup)""$(ls -d "$(find 
/Volumes/ -maxdepth 1
 -type l -print) | sed 's/\/Volumes\///')")""$(pwd -P)"
ls: cannot access '/Volumes//New Main | sed '\''s/\/Volumes\///'\'')': No such 
file or directory
-bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
Pro/2017-09-26-184525/Users/michael/Library: No such file or directory
keybounceMBP:Library michael$ 

Argh.

Anyone? The nesting needed to deal with filenames containing space in a shell 
designed around "spaces break tokens, no files will ever have a space in their 
name" has gotten beyond me here.

___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-26 Thread Macs R We
In Multics, there were something like four different controls in the command 
processor to address problems like this, each of which performed requoting, 
each with slightly different semantics and producing slightly different 
results, and all useful in different contexts.  
(http://www.mirrorservice.org/sites/www.bitsavers.org/pdf/honeywell/multics/AG92-06B_multicsCmds_Nov87.pdf,
 page 3-322.)

As far as I know, Unix has never had any such facility.


> On Sep 26, 2017, at 9:17 PM, Michael  wrote:
> 
> 
> On 2017-09-26, at 7:50 AM, @lbutlr  wrote:
> 
>> On Sep 26, 2017, at 8:44 AM, @lbutlr  wrote:
>>> pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l 
>>> -print` | sed 's/\/Volumes\///')$(pwd -P)"
>> 
>> AFAIC, this works and is shorter, but I don't use pushd myself:
>> 
>> pushd "$(tmutil latestbackup)$(ls -d `find /Volumes/ -maxdepth 1 -type l` | 
>> sed 's/\/Volumes\///')"
> 
> Lacking the current directory at the end, it can't work.
> 
> The longer one?
> keybounceMBP:Library michael$ pushd "$(tmutil latestbackup)$(ls -d `find 
> /Volumes/ -maxdepth 1 -ty
> pe l -print` | sed 's/\/Volumes\///')$(pwd -P)"
> ls: cannot access '/Volumes//New': No such file or directory
> ls: cannot access 'Main': No such file or directory
> -bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
> Pro/2017-09-26-184525/Users/michael/Library: No such file or directory
> 
> ... Yea, my root volume has a space in the name "New Main".
> 
> So how badly  can I nest "$( ?
> 
> keybounceMBP:Library michael$ pushd "$(tmutil latestbackup)""$(ls -d "$(find 
> /Volumes/ -maxdepth 1
> -type l -print) | sed 's/\/Volumes\///')""$(pwd -P)"
>> 
> 
> Missed one, try again
> 
> keybounceMBP:Library michael$ pushd "$(tmutil latestbackup)""$(ls -d "$(find 
> /Volumes/ -maxdepth 1
> -type l -print) | sed 's/\/Volumes\///')")""$(pwd -P)"
> ls: cannot access '/Volumes//New Main | sed '\''s/\/Volumes\///'\'')': No 
> such file or directory
> -bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
> Pro/2017-09-26-184525/Users/michael/Library: No such file or directory
> keybounceMBP:Library michael$ 
> 
> Argh.
> 
> Anyone? The nesting needed to deal with filenames containing space in a shell 
> designed around "spaces break tokens, no files will ever have a space in 
> their name" has gotten beyond me here.
> 
> ___
> MacOSX-talk mailing list
> MacOSX-talk@omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/macosx-talk

___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-27 Thread LuKreme
On Sep 26, 2017, at 22:17, Michael  wrote:
> Yea, my root volume has a space in the name "New Main".

Yeah, I didn’t check for spaces in the host/machine name because I’ve never 
done that (nor would I ever as it breaks too many other things), but the 
solution is simple, just put quotes around the $(find /Volumes/ portion of the 
command.

-- 
This is my signature. There are many like it, but this one is mine.


___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-27 Thread Arno Hautala
On Wed, Sep 27, 2017 at 9:05 PM, Michael  wrote:
>
> keybounceMBP:AdultSwim michael$ pushd "$(tmutil latestbackup)""$(/bin/ls -d 
> "$(find /Volumes/ -maxdepth 1 -type l -print)" | sed 
> 's/\/Volumes\///')""$(pwd -P)"
> -bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
> Pro/2017-09-27-172133/New Main/Volumes/Kleiman Movies/Videos to 
> watch/TV/AdultSwim: No such file or directory
> keybounceMBP:AdultSwim michael$
>
> New Main/Volumes/ does not belong :_)

I get it now. If you're on the boot volume, you want to add that name
to the path. If you're on a different volume, you need to remove
"/Volumes".
The following should do that. It also uses pipes instead of slashes in
the sed commands; it reads better.

push \
"$(tmutil latestbackup)" \
"$(pwd -P | \
sed \
-e 's|/Volumes/|/|' \
-e t \
-e "s|^|"$(\
find /Volumes/ -maxdepth 1 -type l | \
sed 's|/Volumes/|/|')"|"\
)"

-e 's/Volumes/||' # remove the /Volumes prefix
-e t # if the previous replacement succeeded, stop processing
-e "s|^|… # find the likely boot volume name, remove "/Volumes/", and
add it to the beginning of the path


In one line:

pushd "$(tmutil latestbackup)""$(pwd -P | sed -e 's|/Volumes/|/|' -e t
-e "s|^|"$(find /Volumes/ -maxdepth 1 -type l | sed
's|/Volumes/|/|')"|")"


-- 
arno  s  hautala/-|   a...@alum.wpi.edu

pgp b2c9d448
___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-09-28 Thread @lbutlr
On 27 Sep 2017, at 20:35, Arno Hautala  wrote:
> It also uses pipes instead of slashes in the sed commands; it reads better.

I really wish I could manage to remember that sed can do that.

-- 
Apple broke AppleScripting signatures in Mail.app, so no random signatures.

___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk


Re: Getting a command to move to the time machine backup of working dir

2017-11-08 Thread Michael_google gmail_Gersten
This is really difficult, isn't it?

Here's what I got:

In ~/.bashrc:


tmdir () {
set -x
pushd "$(tmutil latestbackup)""$(pwd -P | sed -e 's|/Volumes/|/|' -e t
-e "s|^|"$(find /Volumes/ -maxdepth 1 -type l | sed
's|/Volumes/|/|')"|")"
}

Trying it:

keybounceMBP:Profiles michael$ tmdir
++ tmutil latestbackup
++ pwd -P
+++ find /Volumes/ -maxdepth 1 -type l
+++ sed 's|/Volumes/|/|'
++ sed -e 's|/Volumes/|/|' -e t -e 's|^|//New' 'Main|'
sed: 1: "s|^|//New
": unescaped newline inside substitute pattern
+ pushd '/Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook
Pro/2017-11-08-132156'
/Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook
Pro/2017-11-08-132156 ~/Library/Application Support/Firefox/Profiles
/Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook
Pro/2017-11-08-132156

There is no newline in there in the .bashrc file, except for after the
end of the whole command.
And I don't see any imbalance in the parens/etc, even Vim thinks it's balanced.

And it sure looks like sed somehow added a newline after half of it's args.


On Wed, Sep 27, 2017 at 7:35 PM, Arno Hautala  wrote:
> On Wed, Sep 27, 2017 at 9:05 PM, Michael  wrote:
>>
>> keybounceMBP:AdultSwim michael$ pushd "$(tmutil latestbackup)""$(/bin/ls -d 
>> "$(find /Volumes/ -maxdepth 1 -type l -print)" | sed 
>> 's/\/Volumes\///')""$(pwd -P)"
>> -bash: pushd: /Volumes/TimeMachine/Backups.backupdb/Keybounces MacBook 
>> Pro/2017-09-27-172133/New Main/Volumes/Kleiman Movies/Videos to 
>> watch/TV/AdultSwim: No such file or directory
>> keybounceMBP:AdultSwim michael$
>>
>> New Main/Volumes/ does not belong :_)
>
> I get it now. If you're on the boot volume, you want to add that name
> to the path. If you're on a different volume, you need to remove
> "/Volumes".
> The following should do that. It also uses pipes instead of slashes in
> the sed commands; it reads better.
>
> push \
> "$(tmutil latestbackup)" \
> "$(pwd -P | \
> sed \
> -e 's|/Volumes/|/|' \
> -e t \
> -e "s|^|"$(\
> find /Volumes/ -maxdepth 1 -type l | \
> sed 's|/Volumes/|/|')"|"\
> )"
>
> -e 's/Volumes/||' # remove the /Volumes prefix
> -e t # if the previous replacement succeeded, stop processing
> -e "s|^|… # find the likely boot volume name, remove "/Volumes/", and
> add it to the beginning of the path
>
>
> In one line:
>
> pushd "$(tmutil latestbackup)""$(pwd -P | sed -e 's|/Volumes/|/|' -e t
> -e "s|^|"$(find /Volumes/ -maxdepth 1 -type l | sed
> 's|/Volumes/|/|')"|")"
>
>
> --
> arno  s  hautala/-|   a...@alum.wpi.edu
>
> pgp b2c9d448



-- 
Political and economic blog of a strict constitutionalist
http://StrictConstitution.BlogSpot.com

This message may have been spell checked by a laptop kitten.
___
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk