[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ranger-users] passing / testing macros to shell
From: |
hut |
Subject: |
Re: [Ranger-users] passing / testing macros to shell |
Date: |
Thu, 21 Jan 2016 17:15:45 +0100 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Thu, Jan 21, 2016 at 06:38:03AM +0100, Diederich Hessling wrote:
> Hi there. I couldn't find much about this on the web, so I thought I'd just
> ask here.
> I am not very familiar with this stuff, so... my question might be more
> related to bash or python(?) than being ranger-specific.
> My aim is to use ranger to create a list of files and directories for later
> use. I found that the --choosefiles option works only inside the directory
> one is currently browsing. As the manual says, the "%c" macro is the only one
> that transcends the current dir.
> So I browse my file tree and mark files and dirs with the "yank/copy"
> function.
> I mapped a key to something like 'map td shell echo "%c" >> list_of_stuff'
> with some sed piping to give me line breaks and it works fine.
> I would like that to work also when nothing is yanked/copied, and the shell
> expression then should use "%f" instead.
> I tried to insert a simple shell test in my rc.conf like '[[ -z "%c" ]] &&'
> but apart from not knowing how to correctly pass the macro it seems that
> ranger always gives an error if "%c" is empty.
> What would be the best way to decide whether the %c or %f macro will be
> passed to the shell?
There is the command "save_copy_buffer" which writes the copy buffer to
~/.config/ranger/copy_buffer, maybe that helps you.
To determine if nothing is yanked, you can check the variable
fm.copy_buffer for emptiness. For example:
:eval fm.execute_console("echo SOMETHING IS COPIED") if fm.copy_buffer else
fm.execute_console("echo NOTHING IS COPIED")
you can bind this to a key like any other command with "map X eval ..."
regards, hut