[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ranger-users] previewing a certain file type with external utility
From: |
Gary Johnson |
Subject: |
Re: [Ranger-users] previewing a certain file type with external utility (tricky case?) |
Date: |
Sun, 15 Jul 2018 23:04:01 -0700 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On 2018-07-15, Thoralf Dassler wrote:
> thanks for the quick response. Going with Dimitri's suggestion, I
> have added this section to my ~/.config/ranger/scope.sh:
>
> # Mail
> message/rfc822)
> show "${FILE_PATH}" && { dump | trim; exit 0; }
>
> ${FILE_PATH} is defined in scope.sh as
> FILE_PATH="${1}" # Full path of the highlighted file
>
> In my case ranger should therefore run:
> 'show /home/user/mail/inbox/N' (N is an integer number, it
> represents the file names in /home/user/mail/inbox)
>
> However, what I actually need is: 'show $N', i.e.: I need to
> only pass the file names without the path.
>
> Can '$N' be done in scope.sh? If yes, how would I have to do it?
>
> Explanation: The reason why I need only '$N' is because
> 1) The utility 'show' insists on its dedicated .mh_profile being present;
> 2) 'Path:' must be defined within .mh_profile. The value of
> 'Path:' therefore gets auto-inserted in front of '${FILE_PATH}',
> which does not work of course. Hence I only need '$N'.
Instead of
show "${FILE_PATH}"
use
show "${FILE_PATH##*/}"
See the bash(1) man page, the section on Parameter Expansion, the
description of the ${parameter##word} form.
Regards,
Gary