You are not logged in.

#1 2018-03-26 19:56:53

iduoad
Member
Registered: 2018-01-14
Posts: 17

Shell function (from zshrc) does not work on ranger ?

I added an Extract function to my .zshrc it works fine within Zsh. When I mapped it to a key in ranger, it did not work. Here is how I mapped it (rc.conf)

map X shell extract %f 

Is there a way to use my Shell functions with Ranger or I have to put them in separate scripts

Last edited by iduoad (2018-03-26 21:02:17)

Offline

#2 2018-03-26 20:44:19

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 341
Website

Re: Shell function (from zshrc) does not work on ranger ?

I suggest creating a simple shell script using desired function and map it in ~/.config/ranger/rifle.conf
ie:

ext zip = myscript.sh "$@"
ext tar.gz = myscript.sh "$@"

maybe this would work too

ext tar.gz = map X shell extract %f "$@"
ext zip = map X shell extract %f "$@"

Offline

#3 2018-03-26 21:00:33

iduoad
Member
Registered: 2018-01-14
Posts: 17

Re: Shell function (from zshrc) does not work on ranger ?

Actually I have a lot of functions that I've like to bind them to something in Ranger. And I don't want to create separate scripts for all of them.

Offline

#4 2018-03-26 21:20:30

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 341
Website

Re: Shell function (from zshrc) does not work on ranger ?

Learn how ranger works

https://wiki.archlinux.org/index.php/ra … ssociation

your shell alias && functions will not work in ranger without some editing of ~/.config/ranger/rifle.conf, functions that are more than one liners will need a script to  work, if you dont want to create said scripts, then dont.

Also note the examples of the scripts used for extracting && compressing from above wiki link.

Last edited by cirrus (2018-03-26 21:31:39)

Offline

#5 2018-03-26 21:43:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: Shell function (from zshrc) does not work on ranger ?

This is not a ranger issue, it's just general shell use:

iduoad wrote:

Is there a way to use my Shell functions with Ranger or I have to put them in separate scripts

Shell functions are only defined in interactive shells.  I just took a quick look and I don't see any obvious way to pass the '-i' flag to the shell that ranger spawns, but it certainly could be done.  Short of that, you can specify it in your commands directly:

map X sh -i -c shell extract %f

Though this is pretty ugly if you ask me.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB