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 <[email protected]> wrote:
> On Wed, Sep 27, 2017 at 9:05 PM, Michael <[email protected]> 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 /-| [email protected]
>
> 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
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-talk